Packages  This Package  Prev  Next  Index  

§3.3 Class Dictionary

public  abstract  class  java.util.Dictionary
    extends  java.lang.Object  (I-§1.12)
{
        // Constructors
    public Dictionary();	§3.3.1

        // Methods
    public abstract Enumeration elements();	§3.3.2
    public abstract Object get(Object  key);	§3.3.3
    public abstract boolean isEmpty();	§3.3.4
    public abstract Enumeration keys();	§3.3.5
    public abstract Object put(Object  key, Object  value)	§3.3.6
    public abstract Object remove(Object  key);	§3.3.7
    public abstract int size();	§3.3.8
}
The Dictionary class is the abstract parent of any class, such as Hashtable (I-§3.4), which maps keys to values. Any non-null object can be used as a key and as a value.

As a rule, the equals method (I-§1.12.3) should be used by implements of this class to decide if two keys are the same.

See Also:
hashCode in class Object (I-§1.12.6).

Constructors

Dictionary

public Dictionary()
The default constructor.

Methods

elements

public abstract Enumeration elements()
Returns:
An enumeration (I-§3.11) of the values in the dictionary.
See Also:
keys (I-§3.3.5).

get

public abstract Object get(Object key)
Parameters:
key - a key in this dictionary
Returns:
the value to which the key is mapped in this dictionary; null if the key is not mapped to any value is thise dictionary.
See Also:
put (I-§3.3.6).

isEmpty

public abstract boolean isEmpty()
Returns:
true if this dictionary maps no keys to values; false otherwise.

keys

public abstract Enumeration keys()
Returns:
An enumeration (I-§3.11) of the keys in this dictionary.
See Also:
elements (I-§3.3.2).

put

public abstract Object put(Object key, Object value)
Maps the specified key to the specified value in this dictionary. Neither the key nor the value can be null.
The value can be retrieved by calling the the get method (I-§3.3.3) with a key that is equal (I-§1.12.3) to the original key.

Parameters:
key - the hashtable key
value - the value.
Returns:
the previous value to which the key was mapped in the dictionary, or null if the key did not have a previous mapping.
Throws
NullPointerException (I-§1.40)
If the key or value is null.

remove

public abstract Object remove(Object key)
Removes the key (and its corresponding value) from this dictionary. This method does nothing if the key is not in this dictionary.
Parameters:
key - the key that needs to be removed
Returns:
the value to which the key had been mapped in this dictionary, or null if the key did not have a mapping.

size

public abstract int size()
Returns:
the number of keys in this dictionary.

Packages  This Package  Prev  Next  Index
Java API Document (HTML generated by dkramer on April 22, 1996)
Copyright © 1996 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to doug.kramer@sun.com