/* * For number between -130 and +200 make two instances * of the Integer class for each value. * Why aren't the instances always distinct??? * @author ggtowell * Created: July 20, 2021 */ public class Sttc { public static void main(String[] args) { for (int i = -130; i < 200; i++) { Integer i1 = Integer.valueOf(i); // identityHashCode gives the memory location int ii1 = System.identityHashCode(i1); Integer i2 = Integer.valueOf(i); int ii2 = System.identityHashCode(i2); if (ii1 != ii2) { System.out.println(String.format("%3d %12d %12d", i, ii1, ii2)); } } } }