Possible Duplicate:
Wrapper class and == operator
Saw this code in a website when i was learning about autoboxing..
Integer i1 = 1;
Integer i2 = 1;
// true
System.out.println(i1 == i2);
Integer i3 = -200;
Integer i4 = -200;
// false
System.out.println(i3 == i4);
I can understand why the 2nd comparison gives false (its comparing references). But why is it giving true for the first one ?