File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes HasMap iteration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "HasMap iteration" Watch "HasMap iteration" New topic
Author

HasMap iteration

A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
Hi,

I have a map returned from a function.

Now I wish to get the keys and values from this map..

But i dont have any idea about both the keys as well as values...

I can iterate about the map and get all the values using .get(key);

but how shall i get the keys in the first place..

Thanks,
A Kumar
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
HashMap provides keySet(), values(), and entrySet() that can all be iterated. The last one holds Map.Entry objects with getKey(), getValue(), and setValue().
Sripathi Krishnamurthy
Ranch Hand

Joined: Mar 07, 2005
Posts: 232
you can also use this way.

A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
Thnks....

Did the way u guys mentioned ...

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HasMap iteration