标签:
List list = new ArrayList(); list.add("aa"); list.add("bb"); list.add("cc");
1.for-iter循环
for (Iterator iter = list.iterator(); iter.hasNext();) { String str = (String)iter.next(); System.out.println(str); }
2.迭代器用于while循环
Iterator iter = list.iterator(); while(iter.hasNext()){ String str = (String) iter.next(); System.out.println(str); }
3.for each循环
for(Object str:list){ System.out.println(str); }
4.
for(int i = 0;i<list.size();i++){ System.out.print(list.get(i)+"/t"); }
(注意:Object[] objs=(Object[])list.get(i);)
标签:
原文地址:http://www.cnblogs.com/charles-kun/p/5517775.html