Well, this is happening because of the below code of Integer wrapper class:
public static Integer valueOf(int i) {
if(i >= -128 && i <= IntegerCache.high)
return IntegerCache.cache[i + 128];
else
return new Integer(i);
}
To put it in simple words, when you write,
Integer integer1 = 127;
It means,
Integer integer1 = Integer.valueOf(127);
Thus, for values between -128 to 127, the Integers are kept in cache and are returned multiple times from there whereas, for values lower than -128 or higher than 127, new Integers are generated.