package Integer;
/**
* JDK5推出后推出了一个特性:自动拆装箱
* 该特性是编译器认可的,可以在编译代码时自动补充代码将
* 基本类型与对应的包装类相互装换.
* 这样的好处是我们在编写源代码时可以混用基本类型和引用类型
* 无需再手动代写进行相互的转换工作了.
* @author Administrator
*
*/
public class IntegerDemo3 {
public static void main(String[] args) {
/*
* 下面代码触发了编译器的自动装箱特性,编译器会会在
* 编译后的class文件中补充的代码,将基本类型转换为
* 对应的包装类:
* Integer i=Integer.valueOf(123);
*
*/
Integer i=123;//123
/*
* 下面代码触发的是自动拆箱特性,代码被改为:
* int d=i.intValue();
*/
Integer oo=Integer.valueOf(123);//123
int d=oo.intValue();
System.out.println(oo);
System.out.println(d);
}
}