- Hashtable is synchronized and thread-safe.HashMap is asynchronized and faster.
- HashMap implements Map interface.By using the Map interface it can switched between TreeMap &HashMap.
- HashMap permits the null values as key or value but Hashtable does not.
- HashMap does not guaranteed to store the values in a constant order over a period of time.
- Synchronization can be achieved by the HashMap by using java.util.collections.synchronizedMap(yourHashMap).This feature is added in JDK1.5.
When to go What?
- Is your operation is multithreaded ?: HashTable(less than jdk1.5).
- Is the datatype of key is Integer ? : HashTable has better performance if the data type of the key is Integer.