首页 > 代码库 > Collection Iterator 迭代器

Collection Iterator 迭代器

Collection c=new ArrayList();

c.add(123);

 

//迭代器遍历集合

Iterator i=c.Iterator();

while(i.hasNext())

{

System.out.println(i.next());

}

 

 

//增强for循环 遍历

for(object i:c)

{

System.out.println(i);

}

Collection Iterator 迭代器