Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Anita Morales   on Sep 20 In Java Category.

  
Question Answered By: Guadalupe Rogers   on Sep 20

Move the iterator  declaration to here. You are declaring an iterator, then
trying to modify the container. Once you have your iterator, any changes to
the underlying container could trigger a ConcurrentModificationException.
From the Sun's java documentation:

"This field (modCount) is used by the iterator and list  iterator
implementation returned by the iterator and listIterator methods. If the
value of this field changes unexpectedly, the iterator (or list iterator)
will throw a ConcurrentModificationException in response to the next, remove,
previous, set  or add operations. This provides fail-fast behavior, rather
than non-deterministic behavior in the face of concurrent modification  during
iteration."

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Concurrent Modification Exception Or get search suggestion and latest updates.