wood burning stoves*
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
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: 4343

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

I agree. Here's the link: http://aspose.com/file-tools
subject: Map.Entry interface
Similar Threads
The Java API Documentation and Java 1.7
Reason to create inner class in an interface
Doubt in a practise question
Problem with stack class
Generic Collections