The Stack is one of the popular data structure which supports LIFO (Last In First OUT) operation. Due to LIFO advantage, you can use stack data structure to convert a recursive algorithm to an iterative one. Stack data structure is very easy to implement using an array or linked list, but you don't have to implement it by your own because Java already provides a Stack implementation in java.util.Stack class. This class is a subclass of the Vector class and you should use it whenever you need Stack for your production code, there is no point inventing the wheel again when the focus is on developing your application. At the same time, as a programmer and coder, you should also know how to implement your own stack by using a basic data structure like an array or linked list.
Read more »This post first appeared on Javarevisited: Blog About Java Programmin, please read the originial post: here