Code example for Hashtable

Methods: get, put

0
        // Test for method java.util.Hashtable(int) 
        Hashtable h = new Hashtable(9);
 
        assertEquals("Created incorrect hashtable", 0, h.size());
 
        Hashtable empty = new Hashtable(0);
        assertNull("Empty hashtable access", empty.get("nothing"));
        empty.put("something", "here");
        assertTrue("cannot get element", empty.get("something") == "here");
 
        try { 
            new Hashtable(-1);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
            //expected 
        } 
    } 
 
    /** 
     * java.util.Hashtable#Hashtable(int, float) 
     */