public class IntegerDemo2 { public static void main(String[] args) { //自动装箱 // Integer i = new Integer(10); Integer i = 10; //自动拆箱 int a = i; // int a = i.intValue(); Integer i2 = 10; Integer i3 = 20; Integer i4 = i2 + i3; /* * Integer i3 = new Integer(i.intValue() + i2.intValue()); * */ // 应用: ArrayList li = new ArrayList(); li.add(1); //自动装箱,list.add(new Integer(1)); } }
原文:https://www.cnblogs.com/longesang/p/11262839.html