import java.util.Scanner; interface StackADT { void push() throws Exception; void pop(); void display(); } class StackInterface implements StackADT { int size,top; int arr[]; Scanner s = new Scanner(System.in); StackInterface() { System.out.println("Enter the size of the stack"); size = s.nextInt(); arr = new int[size]; top = -1; } public void push() throws Exception { if(top == arr.length-1) { System.out.println("StackOverflow"); } else { System.out.println("Enter the element to push in the stack"); int element = s.nextInt(); top = top+1; arr[top] = element; } } public void pop() { if(top == -1) { System.out.println("Stack Underflow"); } else { System.out.println("The Popped element is "+ arr[top]); top--; } } public void display() { if(top == -1) { System.out.println("The Stack is empty"); } else { for (int i=0;i