I\'m so very new to Arraylists & iterators & this is the first time I got this exception. I have an ArrayList u & I\'d like to do the following algorithm:
When you are using foreach loop, you are using iterator implicitly.
ConcurrentModificationException occurs when the collection is modified by "simultaneously" with the passage of an iterator over a collection by any means, except for the iterator.
So, use iterator
Iterator iter = u.iterator();
while (iter.hasNext())
in cases you need to modify collection in loop.