import java.util.Stack; public class stackApplication { public static void main(String[] args) { Stack s = new Stack(); if (s.isEmpty()) System.out.println("stack is empty"); s.push(new Integer(5)); s.push(new Integer(-2)); s.push(new Integer(1)); s.push(new Integer(99)); if (s.isEmpty()) System.out.println("stack is empty"); while (!s.isEmpty()) { System.out.println("top of stack value is : "+s.peek()); s.pop(); /* discard the return value from pop() */ } System.out.println("Stack empty, exiting ..."); } } interface StackInterface { /* returns true if stack is empty, true otherwise */ public boolean isEmpty() ; /* return true if stack is full, false otherwise */ public boolean isFull(); /* adds object to stack if stack is not full (let the user beware!) */ public void push(Object x); /* removes and returns object at the top of the stack, fails (ungracefully) if the stack is empty */ public Object pop(); /* returns object at the top of the stack, fails (ungracefully) if the stack is empty */ public Object peek(); } class xStack implements StackInterface { /* returns true if stack is empty, true otherwise */ public boolean isEmpty() {return true;} /* return true if stack is full, false otherwise */ public boolean isFull() { return false;} /* adds object to stack if stack is not full (let the user beware!) */ public void push(Object x) {return;} /* removes and returns object at the top of the stack, fails (ungracefully) if the stack is empty */ public Object pop() {return null;} /* returns object at the top of the stack, fails (ungracefully) if the stack is empty */ public Object peek() {return null;} }