Matsushita's Blog

Implementation of Stack with LinkedList in Java

Implementation of Stack with LinkedList

I defined the Stack class with a top property which is defined as the following explanation.

  • top: the position to insert next Node at next time and the position to get a Node at next time.

When I push the next node, I have to insert the Node before a top node and update top node.