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-10-07 01:48:31
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);
}