Overloading1.java无法通过编译,但Overloading2.java却顺利通过编译。这是为什么?
public class Overloading1 {
static void f(float i, Character... args) {
System.out.println("first");
}
static void f(Character... args) {
System.out.print("second");
}
public static void main(String[] args) {
f(1, 'a');
f('a', 'b');
}
}
public class Overloading2 {
static void f(float i, Character... args) {
System.out.println("first");
}
static void f(char c, Character... args) {
System.out.println("second");
}
public static void main(String[] args) {
f(1, 'a');
f('a', 'b');
}
}
输出:
first
second[/code] |