The java.lang.Integer.valueOf (int) method, by default, returns the object in the cache if the parameter is between 128 and 127, otherwise returns a new Integer (int).
The objects in the cache are initialized the first time the JVM uses the ValueOf method.
You can set system Properties Java.lang.Integer.IntegerCache.high the upper limit of the modified buffer, which defaults to 127. The parameter content should be a string in the form of a decimal number greater than 127, otherwise it will be ignored. The value range is 127-long.max_value, but is strongly converted to int.
When integer is used extensively in the system, increasing the upper limit of the cache can save a small amount of memory.
The upper buffer limit will affect some businesses:
Integer I1 =127; Integer I2=127; if(I1 = =I2) System. out. println (true); ElseSystem. out. println (false); I1= -; I2= -; if(I1 = =I2) System. out. println (true); ElseSystem. out. println (false);
The above code will output by default:
true false
When the modified buffer limit is greater than 128, it becomes:
true true
The integer buffer for Java