Stack & Queue
Initialization
Stack<String> stack = new Stack<>();
Useful methods
element = stack.push(element); // push one in, O(1)
element = stack.pop(); // pop one out, O(1)
element = stack.peek(); // see the top element, O(1)
stack.isEmpty(); // return true or false
l = stack.length();
Last updated
Was this helpful?