Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Iterating through a hash map

 
Bart Wilson
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need help on how to proceed this. I need to iterate through a hash map.
Thanks
 
Bart Wilson
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what I got so far, am I on the right track?
Set entries = someObject.getItems().entrySet();
Iterator iterator = entries.iterator();
while (iterator.hasNext())
{
Map.Entry entry = (Map.Entry)iterator.next();

}
[This message has been edited by Bart Wilson (edited November 13, 2001).]
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following iterates through the keys in a map
Set Keys = yourMap.keySet()
Iterator it = Keys.iterator()
while(it.hasNext())
do whatever...

------------------
Bosun
SCJP for the Java� 2 Platform
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic