When you try to add and
remove items from the Collection/List then it will throw Concurrent
Modification Exception ,to avoid that we need to use below code.
for (Iterator<type> iter = coll.iterator(); iter.hasNext(); )
{
iter.next();
iter.remove();
}
for (Iterator<type> iter = coll.iterator(); iter.hasNext(); )
{
iter.next();
iter.remove();
}
No comments:
Post a Comment