Boxing of an Integer and conservation of space in Java

Apparently, boxing of an int literal initialization into an Integer class will result in two different objects being assigned the same space in memory if the number is 127 or smaller, but different spaces in memory if the number is 128 or larger. Take BoxTest.java: public class BoxTest { public static void main(String [] args) […]