# 잘못된 파라미터 #### CODE <a class='btn btn-default' href='/codes/66490'>Link</a> ``` public class WhatIsWrong { public static void main(String[] args) { double a = square((int) 3.0); // 3.0 => 3 int b = (int) cube(2); // 8.0 => 8 System.out.printf("a = %d, b = %d\n", a, b); } public static int square(int n) { return n * n; } public static double cube(double n) { return n * n * n; } } ``` #### INPUT ``` ``` #### OUPUT ``` a = Exception in thread "main" java.util.IllegalFormatConversionException: d != java.lang.Double at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4302) at java.util.Formatter$FormatSpecifier.printInteger(Formatter.java:2793) at java.util.Formatter$FormatSpecifier.print(Formatter.java:2747) at java.util.Formatter.format(Formatter.java:2520) at java.io.PrintStream.format(PrintStream.java:970) at java.io.PrintStream.printf(PrintStream.java:871) at WhatIsWrong.main(WhatIsWrong.java:5) ```
## 변수 a의 타입이 double 이쥬? 따라서, printf에서 %f로 받아줘야 합니다. ``` System.out.printf("a = %f, b = %d\n", a, b); // a = 9.0, b = 8 ```