File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

iterate through a hashMap

 
C hurst
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I was wondering which is the best way of iterating through a hashmap. I cannot use iterator as it isn't define for HashMap. Should I cast the hashMap to some other data structure and iterate through that.
 
Don Kiddick
Ranch Hand
Posts: 580
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you're only interested in the values :

T.
[ February 04, 2003: Message edited by: Don Kiddick ]
 
Neil Laurance
Ranch Hand
Posts: 183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try something like:

Cheers, Neil
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at Section 12.3 of David J. Eck's Introduction to Programming Using Java. About a third of the way down the page is the "Views, SubSets, and SubMaps" section that discusses iterating through all of the associations in a Map.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic