(笔记)J2EE中如何运用Autoboxing/Unboxing--New Features of J2EE
public static void boxing(){
(1)Autoboxing 装箱 int i=9;
Integer o_i=new Integer (i);
(2)Unboxing 拆箱 int j=o_i.intValue();
(3)利用list数组 List <Integer>list=new ArrayList<Integer>();
list.add(i);
list.add(j);
(4)在J2EE中直接可以调用o_i 而无需Unboxing 拆箱 list.add(o_i);
Iterator<Integer> it =list.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
}
public static void main(String[] args) {
boxing();
}