public class TestOverload {
public void go(Short n){
System.out.println("Short");
}
public void go(int n){
System.out.println("int");
}
public static void main(String[] args) {
TestOverload t = new TestOverload();
short x = 6;
t.go(x);
}
}
为什么输出的是int
jdk5.0不是可以自动装箱吗 为什么不选择装箱而是选择由short到int的类型自动提升
public void go(Short n){
System.out.println("Short");
}
public void go(int n){
System.out.println("int");
}
public static void main(String[] args) {
TestOverload t = new TestOverload();
short x = 6;
t.go(x);
}
}
为什么输出的是int
jdk5.0不是可以自动装箱吗 为什么不选择装箱而是选择由short到int的类型自动提升
public class TestOverload {
public void go(short n){
System.out.println("Short");
}
public void go(int n){
System.out.println("int");
}
public static void main(String[] args) {
TestOverload t = new TestOverload();
short x = 6;
t.go(x);
}
} 注意大小写,是short,不是Short,Short是short的封装类
System.out.println("Short");
}
public void go(int n){
System.out.println("int");
}
public void go(short n){
System.out.println("short");
}
public class TestOverload {
public void go(short n){
System.out.println("Short");
}
public void go(int n){
System.out.println("int");
}
public static void main(String[] args) {
TestOverload t = new TestOverload();
short x = 6;
t.go(x);
}
}
它自然不属于Short这个封装类的对象了,调用时它就调用了下面的方法