package day16_01_collection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
public class CollectionDemo5
{
public static void main(String[] args)
{
//fun();
fun1();
}
public static void fun1()
{
Collection c = new ArrayList();
c.add("zhangsan");
c.add("lisi");
c.add("wangwu");
Iterator it = c.iterator();
c.add("zhaoliu");
while(it.hasNext())
{
System.out.println(c.next());
}
}
我在测试或取迭代器后,再调用add方法抛异常,结果出现无限循环。求解???
|