File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes what does entrySet return?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what does entrySet return??" Watch "what does entrySet return??" New topic

what does entrySet return??

yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120
it returns a set.

so does it contain both the 'key' and 'value' in case of hashmap??
Jelle Klap

Joined: Mar 10, 2008
Posts: 1948

If you take a look at the API documentation for the Map.entrySet() method it should be pretty obvious what exactly is returned.

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32811

Yes. The JavaDoc for Java 5+ shows this a bit more clearly. It says the return type is:

This is a Set of Entry objects. The Entry class is defined within Map and has the key/value pairs.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: what does entrySet return??
jQuery in Action, 3rd edition