Extending java Integer cache
问题 There's a general advice to use Integer.valueOf(int) instead of new Integer(int) because of caching. In JDK 5+, you should really use valueOf because Integer now caches Integer objects between -128 and 127 and can hand you back the same exact Integer(0) object every time instead of wasting an object construction on a brand new identical Integer object. How can extend the range? 回答1: You can use the java.lang.Integer.IntegerCache.high property to increase the size of this cache. ex : java