整数缓冲区

整数缓冲区

  • java预先创建了256个常用的整数包装类型对象。

  • 在实际应用中,对已创建的对象进行重复使用。

    public class Demo02 {
        public static void main(String[] args) {
           Integer integer1=new Integer(100);
           Integer integer2=new Integer(100);
            System.out.println(integer1==integer2);//false
            Integer integer3=Integer.valueOf(100);//自动装箱        int取值范围:-128-127
            Integer integer4=Integer.valueOf(100);
            System.out.println(integer3==integer4);//true
            Integer integer5=Integer.valueOf(200);//自动装箱
            Integer integer6=Integer.valueOf(200);
            System.out.println(integer5==integer6);//false
        }
    }
    

本文作者:努力的小L

本文链接:https://www.cnblogs.com/sx-xiaoL/p/17420639.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   努力的小L  阅读(5)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
展开