SSCCE:
public class Test {
public static void main(String[] args) {
Long a = new Long(1L);
new A(a);
}
static class A {
A(int i) {
System.out.println("int");
}
A(double d) {
System.out.println("double");
}
}
}
输出:
double
不会输出编译错误,程序可以正常运行,并调用 double
参数的构造函数。但是为什么呢?
long long
值放入int
或double
构造函数中,将会出现编译错误。 - SeniorJD