you both kinda right guys (Gunjan ,
Alan). when you create an Integer in range -128 to 127
with boxing it is guaranted to box to the same object. However you didnt create the i2 Integer object with Boxing you constructed it, remember whenever you create an object with 'new' a new object will be made on the heap. i3 and i4 which i added box to the same object, hope this helps
Integer i1 = 125;
Integer i2 = new Integer(125);
System.out.println(i1==i2); //false
Integer i3 = 125;
Integer i4 = 125;
System.out.println(i3==i4); //true
[ May 24, 2007: Message edited by: Louis Moloney ]