//包装类
//装箱:基本数据类型转换为引用类型
//拆箱:引用类型转换为基本数据类型
public class Example19 {
public static void main(String[] args) {
//装箱:基本数据类型转换为引用类型
int a = 20; //类型
Integer in = new Integer(a); //实例化
System.out.println(a);
}
}
public class Example20 {
public static void main(String[] args) {
//拆箱:引用类型转换为基本数据类型
Integer num = new Integer(20); //包装类
int a = 10; //变量
/num是对象,要调用intValue()方法,将Integer对象转为int
int sum = num.intValue() + a; /
System.out.println("sum=:" + sum);
}
}