Integer a0 = 127; Integer a1 = 127; Integer b0 = 128; Integer b1 = 128; int c = 128; System.out.println(a0 == a1); >>>> true //Integer 对象-128 ~ 127 会缓存,不会新建对象 所以相等 System.out.println(b0 == b1); >>>> false //对象-128 ~ 127 会缓存 但是之外的数据会重新new System.out.println(b0 == c); >>>> true //这里Integer 会自动拆箱成int类型