Linear data structure.
First In Last Out.
push: O(1) pop: O(1) peek: O(1)
In Java, there is a Stack class.
A more complete and consistent set of LIFO stack operations is provided by the Deque interface and its implementations, which should be used in preference to this class. For example:
Deque<Integer> stack = new ArrayDeque<Integer>();
Implementation of Stack
1. Use array
2. Use linked list
Example: