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);
}
时间: 2024-12-07 20:34:41
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);
}