Difference between HashMap and HashTable in Java

FeaturesHashMapHashTable
SynchronizationNot synchronized (not thread safe)Internally synchronized (thread safe)
Null ElementsAllows one null key and any number of null valuesDoesn’t allow null keys and null values
IteratorsReturns fail-fast iteratorsReturns fail-safe Enumerations
Class ExtensionExtends AbstractMap classExtends Dictionary class
TraversalReturns only iteratorsReturns both Iterator and Enumeration
SpeedFastSlow
Legacy ClassNot a legacy classIs a legacy class
Preferred UsePreferred in single-threaded applications; for multi-threaded, wrap using Collections.synchronizedMap()Not preferred nowadays for multi-threaded applications; ConcurrentHashMap is a better option