Java Dictionary Class
The Dictionary class is an abstract class used to store key/value pairs, similar to the Map class.
Given a key and a value, you can store the value in a Dictionary object. Once the value is stored, you can retrieve it by its key. So like Map, Dictionary can also act as a key/value pair list.
The abstract methods defined by Dictionary are shown in the following table:
| No. | Method Description |
| 1 |
Enumeration elements( ) Returns an enumeration of the values in this dictionary. |
| 2 |
Object get(Object key) Returns the value to which the key is mapped in this dictionary. |
| 3 |
boolean isEmpty( ) Tests whether this dictionary has no mapping from keys to values. |
| 4 |
Enumeration keys( ) Returns an enumeration of the keys in this dictionary. |
| 5 |
Object put(Object key, Object value) Maps the specified key to the specified value in this dictionary. |
| 6 |
Object remove(Object key) Removes the key (and its corresponding value) from this dictionary. |
| 7 |
int size( ) Returns the number of entries (distinct keys) in this dictionary. |
The Dictionary class is obsolete. In actual development, you canimplement the Map interfaceto obtain key/value storage functionality.
Other Extensions
Java Data Structures