The Dictionary
class is completely full of abstract
methods. In other words, it should have been an interface. It
forms the basis for key-value pair collections in the historical
collection classes, with its replacement being Map
in
the new framework. Hashtable
and Properties
are
the two specific implementations of Dictionary
available.
The Hashtable
implementation is a generic dictionary
that permits storing any object as its key or value (besides null
).
With the Java 2 SDK, version 1.2, the class has been reworked
into the Collections Framework to implement the Map
interface. So you can use the original Hashtable
methods or the newer Map
methods. If you need a
synchronized Map
, using Hashtable
is slightly
faster than using a synchronized HashMap
.
The Properties
implementation is a specialized Hashtable
for working with text strings. While you have to cast values
retrieved from a Hashtable
to your desired class, the Properties
class allows you to get text values without casting. The class
also supports loading and saving property settings from an input
stream or to an output stream. The most commonly used set of
properties is the system properties list, retrieved by System.getProperties()
.