Package java.util Previous
Previous
Java API
Java API
Index
Index
Next
Next

Class Dictionary

Constructors , Methods

public  abstract  class  java.util.Dictionary
    extends  java.lang.Object  
{
        // Constructors
    public Dictionary();	

        // Methods
    public abstract Enumeration elements();	
    public abstract Object get(Object  key);	
    public abstract boolean isEmpty();	
    public abstract Enumeration keys();	
    public abstract Object put(Object  key, Object  value)	
    public abstract Object remove(Object  key);	
    public abstract int size();	
}

The Dictionary class is the abstract parent of any class, such as Hashtable , 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 should be used by implements of this class to decide if two keys are the same.
See Also: hashCode in class Object .


Constructors


Dictionary

public Dictionary() 

The default constructor.


Methods


elements

public abstract Enumeration elements() 

Return Value:

Returns An enumeration of the values in the dictionary.

See Also: keys .


get

public abstract Object get(Object  key) 

Return Value:

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.

ParameterDescription
key a key in this dictionary

See Also: put .


isEmpty

public abstract boolean isEmpty() 

Return Value:

Returns true if this dictionary maps no keys to values; false otherwise.


keys

public abstract Enumeration keys() 

Return Value:

Returns An enumeration of the keys in this dictionary.

See Also: elements .


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 with a key that is equal to the original key.

Return 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.

ParameterDescription
key the hashtable key
value the value.

Throw:

NullPointerException

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.

Return Value:

Returns the value to which the key had been mapped in this dictionary, or null if the key did not have a mapping.

ParameterDescription
key the key that needs to be removed


size

public abstract int size() 

Return Value:

Returns the number of keys in this dictionary.



Top© 1996 Sun Microsystems, Inc. All rights reserved.