写出一下程序代码的输出结果
有彩蛋!
public class Main {
public static void main(String[] args) {
Integer a = 300;
Integer b = 300;
System.out.println(a == b);
Integer c = 100;
Integer d = 100;
System.out.println(c == d);
}
}
False
True
解释:
Integer声明的变量的值 在[-128,127]范围 地址指向相同(byte范围的数 是从常量池中获取,)