关于JVM中缓存的Integer的范围 [英] On the range of Integer cached in JVM
本文介绍了关于JVM中缓存的Integer的范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
最近,我发现一个问题,为什么JVM缓存-128〜127中的值,而我刚发现方法IntegerCache()和valueOf()表示规则,但是为什么它是从-128〜127中的原因呢?简而言之,这些数字是最常用的数字,并且值得花费256个实例进行缓存的成本/报酬.
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 ?
解决方案
Simply put, these numbers are the most common ones required and the cost/reward of caching 256 instances is worth while.
这篇关于关于JVM中缓存的Integer的范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文