Blog
Comment
Java HashMap vs HashTable
Java HashMap Interview Questions
Both HashMap and HashTable store key/pair values. They differ in mainly in thread safety, performance, and acceptance of null keys.
Thread safety
HashTable is the synchronized version of HashMap. This means HashTable is thread safe whereas HashMap is not.
With that said, you can easily "synchronize" a HashMap like:
Map m = Collections.synchronizedMap(hashMap)
Null
HashMap allows a null key. HashTable does not.
Performance
Synchronized operations are inherently slow. Even if thread safety is important to you, a HashMap can easily be converted int a thread-safe alternative.
A HashMap is also designed to fail fast whereas a HashTable will not.