Non-static nested classes (inner classes) have access to other members of the enclosing class, even if they are declared private. Static nested classes do not have access to other members of the enclosing class. As a member of the OuterClass, a nested class can be declared private, public, protected, or package private.
To instantiate an inner class, you must first instantiate the outer class. Then, create the inner object within the outer object with this syntax : OuterClass.InnerClass innerObject = outerObject.new InnerClass();
public static void main(String[] args){
Stack stack = new Stack();
Stack.Node node = new Stack().new Node();
}
or
public class Stack
{
private class Node{
...
}
...
...
...
public static void main(String[] args){
Node node = new Stack().new Node();
}
}