ITeye博客

(笔记)J2EE中如何运用Autoboxing/Unboxing--New Features of J2EE

danielhjd · 2011-03-23 15:56 · J2EE · 编程语言 · J# · Markdown

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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。