基本数据类型到基本数据封装类: 自动装箱和手动装箱;
基本数据封装类到基本数据类型:手动拆箱和自动拆箱。
//自动装箱:
Integer i=100;//将int直接自动转换成Integer类型,并赋值给i;
//自动拆箱:
Integer num=100; 自动装箱
Integer num2=300; 自动装箱
int ii=num+num2; 自动拆箱
//手动装箱,和手动拆箱:
Integer num3=new Integer(50);包装
Integer num4 = new Integer(60);包装
int i = num3.intValue(); //50 //手动拆箱
int i1 = num4.intValue(); //60 //手动拆箱
int r2= i+i1;
Integer integer = Integer.valueOf(r2); //手动装箱