Stacks
Instantiating a stack
import java.util.Stack;
Stack<Integer> stack = new Stack<>();
Adding to the top of the stack -
.push()stack.push(10); stack.push(20); stack.push(30);Inspecting the item on the top of the stack -
.peek()stack.peek(); // returns 30Removing the item on the top of the stack -
.pop()stack.pop();Inspecting the size of the stack -
.size()stack.size();