import java.util.Hashtable; import java.util.Enumeration; ... // create a new Hashtable Hashtable h = new Hashtable( 149 /* capacity */, 0.75f /* loadfactor */ ); // add some key/value pairs to the Hashtable h.put( "WA" , "Washington" ); h.put( "NY" , "New York" ); h.put( "RI" , "Rhode Island" ); h.put( "BC" , "British Columbia" ); // look up a key in the Hashtable String key = "NY"; String stateName = (String)h.get( key ); out.println( stateName ); // prints "New York" // enumerate all the contents of the hashtable Enumeration keys = h.keys(); while ( keys.hasMoreElements() ) { key = (String)keys.nextElement(); stateName = (String)h.get( key ); out.println( key + " " + stateName ); // prints lines of the form NY New York // in effectively random order. } // end while