public static void main(String[] args) {
Integer i = 127;
Integer j = 127;
System.out.println(i == j);//true
Integer e = 128;
Integer f = 128;
System.out.println(e == f);//false
System.out.println(e.equals(f));//true
Integer a = -128;
Integer b = -128;
System.out.println(a == b);//true
Integer c = -129;
Integer d = -129;
System.out.println(c == d);//false
System.out.println(c.equals(d));//true
}
根据运行结果可得
integer -128 ~ 127 是同一地址值 这个取值范围之外就不能用 == 比较大小了