//Integer内部定义了,静态内部类IntegerCacheprivatestaticclassIntegerCache{staticfinalint low =-128;staticfinalint high;staticfinalInteger cache[];// Integer类型数组,存放-128至127之前的Integer对象static{// 最高限度可以调整,一般都设置为127int 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;// 提前在数组中new好-128值127之前的Integer对象,方便装箱时直接复用,不用每次new对象
cache =newInteger[(high - low)+1];int j = low;// 超过此范围就需要单独调用构造器for(int k =0; k < cache.length; k++)
cache[k]=newInteger(j++);// range [-128, 127] must be interned (JLS7 5.1.7)assertIntegerCache.high >=127;}