Nếu tôi thiết lập một iterator cho myList:Điều gì xảy ra nếu bạn gọi cùng một trình lặp hai lần trên cùng một bộ sưu tập?
Iterator iter = myList.iterator();
while(iter.hasNext())
{
MyObj myObj = (MyObj)iter.next();
doPrint(myObj.toString());
}
Và tôi gọi nó là một lần thứ hai:
while(iter.hasNext())
{
MyObj myObj = (MyObj)iter.next();
doPrint(myObj.toString());
}
nó sẽ quay trở lại để bắt đầu của bộ sưu tập lần thứ hai tôi gọi nó ?
Tại sao bạn không thử? – Fortega
java.util.ConcurrentModificationException –