This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Map.Entry interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

Map.Entry interface

Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

I am wondering.. is there any meaning of Map DOT Entry(Map.Entry) identifier ?
Source:http://docs.oracle.com/javase/7/docs/api/java/util/Map.Entry.html


OCA7
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4537
    
    8

The DOT means it's an interface nested within the Map interface. It's done like that because it doesn't really have a sensible meaning other than in the context of a Map. It's a class that's used to encapsulate a key/value pair in a Map.

When you're iterating over a Map, you can use the keySet() method to get a collection of the keys, or the values() method to get a collection of the values. But you often want to iterate over both at the same time. In that case the most efficient way is to use the entrySet() method, which returns a collection of Map.Entry objects, so you get both the key and value together.
Enkita mody
Ranch Hand

Joined: Aug 06, 2012
Posts: 333

 
jQuery in Action, 3rd edition
 
subject: Map.Entry interface
 
jQuery in Action, 3rd edition