Stack
Stack
class from Collection Framework class can be used.
Creating
Stack<Integer> stack = new Stack<>();
Pushing
stack.push(i)
Popping
Integer i = stack.pop()
Peeking
Returns last element without removing.
Integer i = stack.peek()
Searching
Returns position of the element.
Position starts from 1(not 0) and is counted from the topmost(last) element.
Returns -1 if element is not found.
Integer pos = stack.search(element);