import java.util.*;

class phone2 extends TreeMap
{
   public phone2()
    {super();
  }

   public String getPhone(String n)
    {return (String)get(n);
    }

     public void printAll()
      {Set s = keySet();    // note we had to use a Set because no iterator for Map
      Iterator i = s.iterator();
       while (i.hasNext())
        {System.out.println(i.next());
     	}
   }

    public boolean contains(String n)
      {
   	   return containsKey(n);
       }
 }
___________________________________________________
import java.io.*;
import java.util.*;

public class driver
{public static input in = new input();

public static void main(String[] args) throws IOException
 {phone2 p = new phone2();
 String s = "Tom";
 String m = "336";
  p.put(s,m);
   p.put("Tom","336-3232");
    p.put("Steve","234-2123");

   System.out.println("Names on file are :");
     p.printAll();  // not preorder traversal of binary search tree

  System.out.println("Enter name to find ");
    s= in.getString();

   if (p.contains(s))
    {
    String ph = p.getPhone(s);
    System.out.println("Phone # is "+ph);
     }
    else
     System.out.println("Name not on file ");
}}