比如说int和Integer,前者是基本数据类型,后者是对象。
int t = 1; t. 后面是没有方法滴。
Integer t =1; t. 后面就有很多方法可让你调用了。
自动装箱(成了一个对象!)
Integer i = 100;
Integer i = Integer.valueOf(100); //等同于上一句
自动拆箱(不再是一个对象!)
Integer i = 10; //装箱
int t = i;
int t = i.intValue(); //等同于上一句