class MyStack { Node theStack=null; boolean isEmpty(){ return theStack==null; } T top() throws StackException{ if(isEmpty()) throw new StackException("top-operation on empty Stack"); else return theStack.content; } void pop() throws StackException{ if(isEmpty()) throw new StackException("pop operation on empty stack"); else theStack=theStack.next; } void push(T elt){ Node nd = new Node(elt,theStack); theStack=nd; } class Node { T content; Node next; Node(T content, Node next){ this.content=content; this.next=next; } } }