HashMap vs. HashTable

Key Differences





Comparison Chart
.
Return
Implementation
HashMap and HashTable Definitions
HashMap
HashTable
Definition of HashMap
HashMap is the important data structure in the Collection Framework in Java. HashMap is not thread safe is not synchronized internally so HashMap is not safe to use in multi-threaded applications. But it can be safe for multi threaded applications by synchronizing it externally using Collections.synchronized() method. It implements the Map interface by extending AbstractMap class. Maximum one null key is allowed by HashMap and any number of the null values is also allowed. Iterator returned by HasMap are fail-fast in nature. Performance of HashMap is good and is thus fast as compare to the HashTable.
Definition of HashTable
HashTable is the important data structure in the Collection Framework in Java. HashTable is thread safe and is synchronized internally. Therefore it is safe to be used for multi-threaded applications. It implements the Map interface by extending Dictionary class. It neither allows a single null key nor the null value. HashTable is a legacy class and is considered as due to depreciation. Enumeration returned by the HashTable are fail-safe in nature.