• Post Reply Bookmark Topic Watch Topic
  • New Topic

avoiding ConcurrentModifciation  RSS feed

 
Carl Jenkins
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all -

I am iterating (or tying to) over a list and needed to remove one or more items from this list. I keep running into the ConcurrentModification exception.

I have read that java 5 has the CopyOnWrite to help with this but I need something in java 1.4...

So far I have been unsuccessfully in figuring out how to get around this issue with out actually catching the exception and re-calling the method which I am not sure would work yet but would rather not do.

Any help would be great!
 
Carl Jenkins
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the answer <embarrassed> with a quick search on this forum</embarrassed>

What I need to do is call remove()from the iterator not the list!
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why be embarrassed? You managed to get the answer and tell others what it was. More something to be pleased about.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!