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 Map.Entry interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

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 ?

Matthew Brown

Joined: Apr 06, 2010
Posts: 4517

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

It is sorta covered in the JavaRanch Style Guide.
subject: Map.Entry interface