Tony Stark Tony Stark - 3 years ago 149
Java Question

Replacement for obsolete Hashtable class in Java

When I tried to use the hashtable class, Netbeans gave me an error saying:


While still supported, these classes were made obsolete by the JDK1.2 collection classes, and should probably not be used in new development.


However, I can't seem to find an example online on a better replacement for
Hashtable
. Any suggestions?

Answer Source

The most direct replacement of a Hashtable is a HashMap.

On difference that could be important is that all relevant methods of Hashtable are synchronized while they are not synchronized on HashMap.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download