public static void test(double a){
System.out.println("double: "+a);
}
public static void test(long a){
System.out.println("long : "+a);
} public static void test(Integer a){
System.out.println("Integer: "+a);
}
在main中,我调用 test(2);请问各位 这里应该执行哪一个方法?说明原因。不要去运行了再来说答案,呵呵,各位可以自检一下基础如何。
System.out.println("double: "+a);
}
public static void test(long a){
System.out.println("long : "+a);
} public static void test(Integer a){
System.out.println("Integer: "+a);
}
在main中,我调用 test(2);请问各位 这里应该执行哪一个方法?说明原因。不要去运行了再来说答案,呵呵,各位可以自检一下基础如何。
System.out.println("long : "+a);
}
没int 没long 就Integer先widden->再向上转型->最后比较args
System.out.println("long : "+a);
} 呢???应该是执行哪一个?
不会调用Integer
Integer要经过装箱操作
高级重载优先级
1.widden
2.boxing
3.var-args