UNB/ CS/ David Bremner/ teaching/ java/ PhoneList.java
public class PhoneList{
    private PhoneNode head;
    
    public PhoneList(){
        head=null;
    }

    public void insert(String name, String number){
        PhoneNode newNode=new PhoneNode(name,number);
        
        newNode.setNext(head);

        head=newNode;
    }

    public void print(){
        for (PhoneNode current=head; 
             current!=null; current=current.getNext()){
            current.print();
        }
    }

    public static void main(String[] args){
        PhoneList friends=new PhoneList();

        friends.insert("me", "555-1212");
        friends.insert("myself", "555-1213");
        friends.insert("myself", "555-1214");

        friends.print();
    }
}