JAVA-自动装箱和拆箱

package com.itheima;

public class integerDemo03 {
    public static void main(String[] args) {
        //装箱:把基本数据类型转化为对应的包装类类型;
//        Integer i = Integer.valueOf(100);
        Integer li =100;//Integer.valueOf(100);

        //拆箱:把包装类类型转化为对应的基本数据类型;
        li+=200;
        System.out.println(li);
        /*
        li=li+200;
        li=li.intvalue()+200;//自动拆箱
        li=300;//Integer.valueOf(300);


         */
    }
}

posted @ 2022-11-06 15:53  NiceTwocu  阅读(14)  评论(0编辑  收藏  举报