在下面的一段代码中
class Main {
void m1(double x){
System.out.println("double");
}
void m1(float x){
System.out.println("float");
}
void m1(long x){
System.out.println("long");
}
void m1(byte x){
System.out.println("byte");
}
void m1(short x){
System.out.println("short");
}
void m1(int x){
System.out.println("int");
}
public static void main(String[] args) {
Main m = new Main();
m.m1(1);
}
}
为什么输出是“int”而不是“byte”或“long”或“short”或“float”或“double”?
如果按照从“byte”->“short”->“int”->“long”->“float”->“double”的自动转换,那么输出应该打印“double”对吗?
( https://www.geeksforgeeks.org/type-conversion-java-examples/ )
幕布斯7119047
波斯汪
长风秋雁
相关分类