public class Printer {
public String show(int n) { return "int"; }
public String show(double n) { return "double"; }
}
// ...
Printer p = new Printer();
System.out.println(p.show(3.0));What is printed?
- Acheck_circle
double
- B
int
- C
Ambiguous overload
- D
Compile-time error
Explanation
The literal 3.0 is a double, so the show(double) overload is selected.