Yes, Hashtable was retrofitted to implement Map, so there is little to distinguish them, apart from Hashtable's methods all beign synchronized (this is like the difference between ArrayList and Vector). And this is not really useful -- if you want a proper threadsafe map, consider ConcurrentHashMap first.
There is no emoticon for what I am feeling!
Edwin Dalorzo
Ranch Hand
Joined: Dec 31, 2004
Posts: 961
posted
0
Hashtable is a legacy class, it existed before the JCF (Java Collections Framework) as well as Vector and Stack.
The main difference with the new HashMap class is that Hashtable is already synchronized, while HashMap is not. That means that you will have to pay a performance price for using Hashtable.
Hashtable has been retrofitted to implement the main JFC Interfaces and AbstractClasses like Map and AbstractMap simply for us to be able to use it as another Collection class.
But Hashtable class originally implemented Dictionary which is an interface similar to Map and it used Enumeration which is an approach similar to Iterator.
The use of Hashtable is discouraged nowadays, and if you need to syncronize a Map you can use Map myMap = Collections.synchronizedMap(anotherMap)