public class Stack { private Node first ; private class Node { private Node next ; private Item data ; } public boolean isEmpty() { return (first == null) ; } public void push(Item newData) { Node oldfirst = first ; first = new Node() ; first.data = newData ; first.next = oldfirst ; } public Item pop() { Item returnVal = first.data ; first = first.next ; return returnVal ; } public static void main( String args[]) { Stack s = new Stack() ; s.push("my") ; s.push("dog") ; s.push("is") ; s.push("old") ; while (!s.isEmpty() ) { System.out.println( s.pop() ) ; } Stack ps= new Stack() ; Person p1 = new Person(17,"Bob") ; ps.push(p1) ; p1 = new Person(18,"Sue") ; ps.push(p1) ; while (!ps.isEmpty() ) { p1 = ps.pop(); p1.Print(); } } }