Stack is first come last out.
Stack supports two basic operations called push and pop. The Push operation adds an element at the top of the stack, and the Pop operation removes an element from the top of the stack.
Stack is an ordered list in which, insertion and deletion can be performed only at one end that is called top.
Stack is a recursive data structure having pointer to its top element.
Applications of Stack
Recursion
Expression evaluations and conversions
Parsing
Browsers
Editors
Tree Traversals
Operations on Stack
There are various operations which can be performed on stack.
Push :
Adding an element onto the stack
Pop :
Removing an element from the stack
Peek :
Look all the elements of stack without removing them.
Other Stack Operations
Check if the stack is empty.
Find the size of the stack.
Search for an element in the Stack.
CODE OF STACK INTERFACE:
public interface Stack{
public Object peek();
public Object pop();
public void push(Object o);
public int size();
}