I have this code:
int i = 128;
Integer a = i;
Integer b = i;
System.out.println("a==i " + (a == i)); // true
System.out.println("b==i " + (b == i)); // true
System.out.println("a==b " + (a == b)); // false
System.out.println("equals ->" + a.equals(i)
+ b.equals(i)
+ a.equals(b)); // true, true, true
Then I change my variable i to be 127 :
int i = 127;
Integer a = i;
Integer b = i;
System.out.println("a==i " + (a == i)); // true
System.out.println("b==i " + (b == i)); // true
System.out.println("a==b " + (a == b)); // true !!! look here
System.out.println("equals ->" + a.equals(i)
+ b.equals(i)
+ a.equals(b)); // true, true, true
I don't understand, why "true" changed to "false"?