public abstract class Dictionary<K,V> extends Object
Dictionaryclass is the abstract parent of any class, such as
Hashtable, which maps keys to values. Every key and every value is an object. In any one
Dictionaryobject, every key is associated with at most one value. Given a
Dictionaryand a key, the associated element can be looked up. Any non-
nullobject can be used as a key and as a value.
As a rule, the
equals method should be used by
implementations of this class to decide if two keys are the same.
NOTE: This class is obsolete. New implementations should implement the Map interface, rather than extending this class.
|Modifier and Type||Method||Description|
Returns an enumeration of the values in this dictionary.
Returns the value to which the key is mapped in this dictionary.
Tests if this dictionary maps no keys to value.
Returns an enumeration of the keys in this dictionary.
Maps the specified
Returns the number of entries (distinct keys) in this dictionary.
public abstract int size()
public abstract boolean isEmpty()
isEmptymethod is that the result is true if and only if this dictionary contains no entries.
trueif this dictionary maps no keys to values;
public abstract Enumeration<K> keys()
Enumerationobject is returned that will generate all the keys for which this dictionary contains entries.
public abstract Enumeration<V> elements()
elementsmethod is that an
Enumerationis returned that will generate all the elements contained in entries in this dictionary.
public abstract V get(Object key)
isEmptymethod is that if this dictionary contains an entry for the specified key, the associated value is returned; otherwise,
key- a key in this dictionary.
nullif the key is not mapped to any value in this dictionary.
NullPointerException- if the
public abstract V put(K key, V value)
keyto the specified
valuein this dictionary. Neither the key nor the value can be
If this dictionary already contains an entry for the specified
key, the value already in this dictionary for that
key is returned, after modifying the entry to contain the
If this dictionary does not already have an entry
for the specified
key, an entry is created for the
value can be retrieved by calling the
get method with a
key that is equal to
key- the hashtable key.
value- the value.
keywas mapped in this dictionary, or
nullif the key did not have a previous mapping.
NullPointerException- if the
public abstract V remove(Object key)
key(and its corresponding
value) from this dictionary. This method does nothing if the
keyis not in this dictionary.
key- the key that needs to be removed.
keyhad been mapped in this dictionary, or
nullif the key did not have a mapping.
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
Redwood Shores, CA 94065 USA. All rights reserved.