自动装箱:把基本数据类型转换为包装类型
自动拆箱:把包装类型转换成基本数据类型
public class Demo3 {
public static void main(String[] args) {
Integer i1 = new Integer(10);
Integer i2 = 10;
int i3 = i2;
System.out.println(i2);
System.out.println(i3);
}
}
or
public class Demo3 {
public static void main(String[] args) {
Integer i1 = new Integer(10);
//自动装箱
Integer i2 = 10;
//自动拆箱
int i3 = i2.intValue();
System.out.println(i2);
System.out.println(i3);
}
}
运行结果: