Code example for TreeMap

Methods: firstKey, lastKey, put, remove, subMap

0
        } 
 
    } 
 
    public void test_headMap() throws Exception { 
        TreeMap tree = new TreeMap();
        tree.put(new Integer(0), null);
        tree.put(new Integer(1), null);
        Map submap = tree.subMap(tree.firstKey(), tree.lastKey());
        tree.remove(tree.lastKey());
        assertEquals(submap, tree);
    } 
 
    public void testname() throws Exception { 
        TreeMap nullTree = new TreeMap(new Comparator() {
            public int compare(Object o1, Object o2) {
                if (o1 == null) {
                    return o2 == null ? 0 : -1;
                } 
                return ((String) o1).compareTo((String) o2);
            }