static { // high value may be configured by property int h = 127; String integerCacheHighPropValue = sun.misc.VM.getSavedProperty("java.lang.Integer.IntegerCache.high"); if (integerCacheHighPropValue != null) { try { int i = parseInt(integerCacheHighPropValue); i = Math.max(i, 127); // Maximum array size is Integer.MAX_VALUE h = Math.min(i, Integer.MAX_VALUE - (-low) -1); } catch( NumberFormatException nfe) { // If the property cannot be parsed into an int, ignore it. } } high = h;
cache = new Integer[(high - low) + 1]; int j = low; for(int k = 0; k < cache.length; k++) cache[k] = new Integer(j++);
// range [-128, 127] must be interned (JLS7 5.1.7) assert IntegerCache.high >= 127; }
publicstaticvoidmain(String[] args){ Integer a = new Integer(127); Integer b = new Integer(127); int c = new Integer(127); int d = new Integer(127); int e = new Integer(128); int f = new Integer(128); Integer g = 128; Integer h = 128; Integer i = 127; Integer j = 127; Integer k = 1; Integer l = 2; Integer m = 3; Long n = 3L; System.out.println(a == b); // false System.out.println(a.equals(b)); // true System.out.println(c == d); // true System.out.println(e == f); // true System.out.println(g == h); // false System.out.println(i == j); // true System.out.println(m == (k + l)); // true System.out.println(m.equals(k + l)); // true System.out.println(n == (k + l)); // true System.out.println(n.equals(a + b)); // false }
Compiled from "Test.java" public class stack.Test { public stack.Test(); Code: 0: aload_0 1: invokespecial #1 // Method java/lang/Object."<init>":()V 4: return