可能重复:
带有空参数的 Java 方法分派
为什么这会打印“a(String)”?
public class Test{
public static void main(String[] args){
a(null);
}
public static void a(Object x){
System.out.println("a(Object)");
}
public static void a(String x){
System.out.println("a(String)");
}
public static void a(int x){
System.out.println("a(int)");
}
public static void a(){
System.out.println("a()");
}
}
爪哇版:
java version "1.7.0_04-ea"
Java(TM) SE Runtime Environment (build 1.7.0_04-ea-b228)
Java HotSpot(TM) 64-Bit Server VM (build 23.0-b12, mixed mode)