Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
    Bookmark Topic Watch Topic
  • New Topic

Map.Entry interface

 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
 
Matthew Brown
Bartender
Posts: 4567
8
  • Likes 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Report post to moderator
 
    Bookmark Topic Watch Topic
  • New Topic