* This method will always cache values in the range -128 to 127,
* inclusive, and may cache other values outside of this range.
*
* @param i an {@code int} value.
* @return an {@code Integer} instance representing {@code i}.
* @since 1.5
*/
@HotSpotIntrinsicCandidate
public static Integer valueOf(int i){if(i >= IntegerCache.low && i <= IntegerCache.high)return IntegerCache.cache[i + (-IntegerCache.low)];return new Integer(i);}
在long中也存在这样一个
@HotSpotIntrinsicCandidate
public static Long valueOf(long l){
final int offset = 128;if(l >= -128 && l <= 127){ // will cache
return LongCache.cache[(int)l + offset];}return new Long(l);}