Here we are removing an item from the stack by moving top from the current reference node to the next reference node.
For example, top = top.next
would change the reference from A to B:
SNIPPET
1// A ----> B ----> C A ----> B ----> C
2// ^ ^
3// top top
4
5public int top(){
6 return top.data;
7}
8
9public boolean isEmpty(){
10 return top == null;
11}}