Stack using Array
final class MyStack { private int top; private int [] stack; public MyStack(int size) { top = 0; stack = new int[size]; } public boolean empty() { return (top == 0); } public MyStack push(int val) { stack[top++] = val; return this; } public int pop() { int val = stack[--top]; return val; } }