Integer in = new Integer(1);
Integer in2 = Integer.valueOf(int或者String);
2.拆箱:从包装类对象转换为对应的基本类型。 包装类 --> 基本类型的数据
-intValue()// 以 int 类型返回该 Integer 的值。
int i = in.intValue();
5.2)自动装箱与自动拆箱
从Java 5(JDK 1.5) 开始,有自动装拆
1.自动装箱
-直接把int类型的整数赋值包装类
Integer in = 1; 就相当于 Integer in = new Integer(1);
2.自动拆箱
in是包装类,无法直接参与运算,可以自动转换为基本数据类型,在进行计算
int a = in + 2;// 3