自动装箱/拆箱大大方便了基本类型(8个基本类型)数据和它们包装类的使用
自动装箱 : 基本类型自动转为包装类(int >> Integer)
自动拆箱: 包装类自动转为基本类型(Integer >> int)
public class BoxTest {
public static void main(String[] args) {
int a = 3;
Collection<Integer> c = new ArrayList<Integer>();
c.add(a);//将int类型的3转为Integer类型放到结合中
c.add(a + 10);
for(Integer i : c){
System.out.println(i);
}
}
}