- 装箱就是自动将基本数据类型转换为包装器类型
- 拆箱就是自动将包装器类型转换为基本数据类型
public class Practice{
public static void main(String[] args) {
Integer i1 = 128; // 装箱,相当于 Integer.valueOf(128);
int t = i1; //相当于 i1.intValue() 拆箱
System.out.println(t);
//Integer i1 = 200;
Integer i2 = 128;
if(i1==i2) {
System.out.println("true");
} else {
System.out.println("false");
}
if (i2.equals(i1)) {
System.out.println("true");
}else{
System.out.println("false");
}
}
}
输出结果



