I am a newcomer into Java. Today I saw a piece of code in "Thinking in Java", but I cannot figure out why it produce compile time error.
Code:
public class OverloadingVarargs2 {
static void f(float i, Character... args) {
System.out.println("first");
}
static void f(Character... args) {
System.out.println("second");
}
public static void main(String[] args) {
f(1, 'a');
f('a', 'b');
}
}
Compile complained:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method f(float, Character[]) is ambiguous for the type OverloadingVarargs2