The reason is because the Interger is cashed from -128 to 127, anything that's not in that range the result is not guaranteed.
what do I mean when I say it is cashed.
if you have Interger i =20; and Integer j =20, i and j refers to the same, but if you go like Interger i =128 and Interger j =128, two objects are created in the heap, just like when you go like
String s = new String("Don"); and String k =new String("Don"), so when you use the == to refers to these integers it will say..no they are not equal