码迷,mamicode.com
首页 > 其他好文 > 详细

享元模式

时间:2014-09-14 01:16:56      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   使用   ar   strong   div   sp   log   

享元模式

   String、Character、Integer、Long、Boolean   都使用了享元模式;这里没有浮点型

注意:

     两个Integer对象数字超过127后,自动装箱后不会被缓存,再次装箱同样大于127的数字时
 *  两个>=127的整数对象(Integer,Long)是不相等的

    public static void main(String[] args) {
        Integer i1=128;
        Integer i2=128;
        Integer i3=127;
        Integer i4=127;
        System.err.println(i1==i2);//false
        System.err.println(i3==i4);//true
    }

 

享元模式

标签:style   blog   color   使用   ar   strong   div   sp   log   

原文地址:http://www.cnblogs.com/muzhongjiang/p/3970549.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!