Click here to Skip to main content
15,920,896 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Recently,I found a problem that why JVM caches the values from -128~127 , and I just found the method IntegerCache() and valueOf() says the rules but what is the reason why it is from -128~127 ?
Posted

1 solution

Simply put, these numbers are the most common ones required and the cost/reward of caching 256 instances is worth while.
 
Share this answer
 
Comments
mqslll 22-Aug-12 11:00am    
And this is the reason ? And this is the JVM character , just caches 256 instances?
Nagy Vilmos 22-Aug-12 11:16am    
Probably only need the first 50, but it doesn't cost much in resources so 256 is as good a choice as any other seeing as it is a single byte.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900