1.概述
我们都知道 java Integer是有缓存的,缓存范围是 -128~127
。但是这个值是一定的吗?
不一定。看源码。缓存大小居然可以改变
/**
* Cache to support the object identity semantics of autoboxing for values between
* -128 and 127 (inclusive) as required by JLS.
*
* The cache is initialized on first usage. The size of the cache
* may be controlled by the {@code -XX:AutoBoxCacheMax=<size>} option.
* During VM initialization, java.lang.Integer.IntegerCache.high property
* may be set and saved in the private system properties in the
* sun.misc.VM