Code example for Hashtable

Methods: get

0
        Map map = new TreeMap();
        Object firstVal = "Gabba";
        Object secondVal = new Integer(5);
        map.put("Gah", firstVal);
        map.put("Ooga", secondVal);
        Hashtable ht = new Hashtable(map);
        assertTrue("a) Incorrect Hashtable constructed",
                ht.get("Gah") == firstVal);
        assertTrue("b) Incorrect Hashtable constructed",
                ht.get("Ooga") == secondVal);
 
        try { 
            new Hashtable(null);
            fail("NullPointerException expected");
        } catch (NullPointerException e) {
            //expected 
        } 
    } 
 
    /** 
     * java.util.Hashtable#Hashtable(java.util.Map)