Reputation: 435
I have seen a static nested classes Node and Entry in all Java Collection Interfaces, i want to know that what is the use of these classes and how can i use Them directly?
Upvotes: 0
Views: 1862
Reputation: 435
Result of javap tool on Hashmap$Node Class
Node class is also implementing the Entry interface present in Map as well as Hashmap has Static nested Entry Class too. May Be the Docs on oracle was not Updated with the changes the made in Jdk.
Upvotes: 0
Reputation: 2660
Map.Entry is a key and its value combined into one class. The allows you to iterate over Map.entrySet() without iterating over Keyset first.
for example : If mp is a Map
for (Map.Entry<String, String> entry : mp.entrySet())
{
System.out.println(entry.getKey() + " " + entry.getValue());
}
I don't see Node as a nested class in the docs.
Upvotes: 2