这道题答案为什么是C,而不是Short Long?

如图所示:
2025-02-26 04:07:58
推荐回答(3个)
回答1:

就是short long啊 

回答2:

基本数据类型 short,byte,char 编辑器会把它转化成int型
注意参数是 Short--不是short
参考代码如下
public class Yikes {
public static void go(Long n) {
System.out.println("Long");
}
public static void go(Short n) {
System.out.println("Short");
}
public static void go(int n) {
System.out.println("int");
}
public static void main(String[] args) {
short y = 6; // short,byte,char在进行运算时会自己转化成int型
long z = 7;
Short x = 8; //Short是short的包装类
go(y);//输出int
go(z);//输出 long
go(x); // 输出Short
}
}

回答3:

先自动类型提升,再自动装箱