aspose file tools*
The moose likes Beginning Java and the fly likes how to delete the map elements when iterating the map Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to delete the map elements when iterating the map" Watch "how to delete the map elements when iterating the map" New topic
Author

how to delete the map elements when iterating the map

jing hu
Ranch Hand

Joined: Jun 30, 2009
Posts: 63
I want to delete some elements when iterating the map.

Like this.


but it will fail and throw java.util.ConcurrentModificationException. So How can I modify the map when iterating it.
I want to know a convenient method which do not need many codes.
Thanks
Aurelian Tutuianu
Ranch Hand

Joined: May 13, 2004
Posts: 86
replace line 19 with:


http://javasign.blogspot.com/
jing hu
Ranch Hand

Joined: Jun 30, 2009
Posts: 63
Thanks, I get it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to delete the map elements when iterating the map