Well henry if you create an Integer using autoboxing (i.e. the syntax Integer.valueOf()), then if the value is in the range of -128 to 127, then the Integer object created will be taken from an Integer pool of objects.
Integer i1 = 10; Integer i2 = 10;
will refer to the same object. This is why i1 == i2 will result in true. But if the value is out of this range, then the new objects will be created every time.
Integer i1 = 2000; Integer i2 = 2000;
will refer to different objects. This is why i1 == i2 this time will result in false.
Also remember that using the new Integer() syntax will always result in a new object no matter whatever the value is.
Also as far as I know, this pooling applies to Byte and Short too.
If the value p being boxed is true, false, a byte, a char in the range \u0000 to \u007f, or an int or short number between -128 and 127, then let r1 and r2 be the results of any two boxing conversions of p. It is always the case that r1 == r2.
Note that this applies only to autoboxing, so be sure to note what Ankit said above: Whenever you create a new instance using "new," you will get a new object.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org