I learnt that static class is a class whose members MUST be accessed without an instance of a class.
In the below code from java.util.HashMap, jdk 1.8,
public class HashMap<K,V> extends AbstractMap<K,V>
implements Map<K,V>, Cloneable, Serializable {
.........
static class Node<K,V> implements Map.Entry<K,V> {
final int hash;
final K key;
V value;
Node<K,V> next;
Node(int hash, K key, V value, Node<K,V> next) {
this.hash = hash;
this.key = key;
this.value = value;
this.next = next;
}
........
}
..........
}
What is the java syntax to invoke a constructor
Node(int hash, K key, V value, Node<K,V> next){...}
of a nested static class Node?
More correctly, a static nested class is a class whose instances are instantiated without any reference to an instance of the enclosing class.
A static nested class is regarded as a member of the enclosing class (along with its methods and fields). However, in every way that matters, a static nested class functions just like a top level class.
To create an instance of a static nested class, you use this syntax: