实验06——java自动封箱、自动拆箱

package cn.tedu.demo;

/**
 * @author 赵瑞鑫 E-mail:1922250303@qq.com
 * @version 1.0
 * @创建时间:2020年7月17日 上午9:01:30
 * @类说明:自动封箱:把基本数据类型封装为此类型的封装类类型 ; 自动拆箱:把对象中的数值转成基本数据类型
 */
public class Demo1 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        // 自动封箱
        Integer i = 8;
        Integer i2 = new Integer(8);
        Integer i3 = new Integer(3);
        // 自动拆箱//实际上等于调用了System.out.println(i2.intValue()+i3.intValue());
        System.out.println(i2 + i3);

    }
}

 

posted on 2020-07-28 19:44  Winer_Jiu  阅读(122)  评论(0)    收藏  举报

导航