自动装箱与拆箱

来源:互联网 发布:安徽南瑞继远 知乎 编辑:程序博客网 时间:2024/06/08 02:34

Long a=127;

Long b=127;

a==b;    //  true

Long c=128;

Long d=128;

c==d;  // false

Long,Integer,Boolean 等都有缓存,在不超过一个字节的时候

Double,Float则没有用缓存

Long e=12345;

long f=12345;

e==f';   // true,这个对象e会进行自动拆箱,相当于e.getValue()==f进行比较;

原创粉丝点击