基本数据的自动拆装箱及享元设计模式

来源:互联网 发布:淘宝上怎么发图给卖家 编辑:程序博客网 时间:2024/06/06 00:15
public class AutoBox {    public static void main(String[] args) {        Integer intObject = 3;//自动装箱        int num = intObject+12;//自动拆箱        Integer i1 = 3;        Integer i2 = 3;        // i1 和 i2是一个对象        Integer i3 = 137;        Integer i4 = 137;        // i2 和 i3不是一个对象,当Integer数据在 -128 ~ 127之间时,会放入到常量池中        System.out.println(num);    }}
0 0
原创粉丝点击