首页 > 其他 > 详细

28.6 Integer 自动装箱和拆箱

时间:2019-07-29 14:13:13      阅读:85      评论:0      收藏:0      [点我收藏+]

 

public class IntegerDemo2 {
    public static void main(String[] args) {
        //自动装箱
//    Integer i = new Integer(10);
        Integer i = 10;

        //自动拆箱
        int a = i;
//    int a = i.intValue();

        Integer i2 = 10;
        Integer i3 = 20;
        Integer i4 = i2 + i3;
        /*
         * Integer i3 = new Integer(i.intValue() + i2.intValue());
         *
         */

//    应用:
        ArrayList li = new ArrayList();
        li.add(1); //自动装箱,list.add(new Integer(1));
    }
}

 

28.6 Integer 自动装箱和拆箱

原文:https://www.cnblogs.com/longesang/p/11262839.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!