How to use Iterator in HashMap in Java Program
Tutorials Shared by the Internet Community
Total Hits - 30581
Total Votes - 101 votes
Vote Up - 45 votes
Vote Down - 56 votes
Domain - javarevisited.blogspot.com
Category - JAVA/Collections
Submitted By - Javin Paul
Submitted on - 2011-11-02 06:28:58
Iterators in Java are core of Collection package. They provide most important traversing functionality around objects stored in Collections.
No matter whether your objects are stored inside ArrayList, LinkedList, HashMap, HashSet or Vector , you can effectively use Iterator to navigate inside collection and same time remove objects from Collection safely. There are two kinds of Iterator in Java fail-safe and fail-fast, fail-safe iterator handles failure scenario elegantly while fail-fast iterator throws ConcurrentModification Exception. This article gives a nice overview of Java Iterator and ListIterator and suggest how can you use both iterators based on scenarios and requirement. More detail...