// File: TestHashtable2.java // // Author: Rahul Simha // Created: Sept 23, 1998 // // Hashtables: duplicates. import java.util.Hashtable; public class TestHashtable2 { public static void main (String[] argv) { Hashtable h = new Hashtable (); // Insert a string and a key. h.put ("Ali", "Anorexic Ali"); h.put ("Bill", "Bulimic Bill"); h.put ("Chen", "Cadaverous Chen"); h.put ("Dave", "Dyspeptic Dave"); // Only one value can be stored for a particular key. // Old value with same key is deleted. h.put ("Dave", "Duplicitous Dave"); String d = (String) h.get ("Dave"); System.out.println (d); // Prints "Duplicitous Dave" // You can get back the old value at the // time of insertion. String c = (String) h.put ("Bill", "Blasphemous Bill"); System.out.println (c); // Prints "Bulimic Bill" // The return value is null otherwise. String e = (String) h.put ("Ed", "Egregious Ed"); System.out.println (e); // Prints "null". } }