We all know that Java has a cache for Integer
(and some other types) for number in the range [-128, 127]
which are considered to be \"commonly used
Found out that there is already an unresolved RFP on this.
Joe Darcy commented on the issue :
It is conceivable that it would be helpful to cache a greater range of negative number as well, but as of yet there has been no pressing need to do so.
Note that the RFP offer a poor workaround if ever someone was interested in using this before it is handled :
No workaround possible for increasing the size of the cache apart from Implementing your own cache and reffering to this first before going to the java.lang.Integer class. This is obviously not good as it requires calls to other classes rather than just the default use of the Integer.valueOf(int i) call.