今天在群里有人发了一个题目
Integer i1= 127;
Integer i2=127;
System.out.println(i1==i2);
i1=128;
i2=128;
System.out.println(i1==i2);
刚开始以为true,true;
后来发现是true,false;
原来Integer的默认缓存常量是-127~127之间 超出了的话就会创建一个不同内存空间。
最后
以上就是大力菠萝最近收集整理的关于Integer缓存问题的全部内容,更多相关Integer缓存问题内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复