What differences exist between HashMap and Hashtable ?
HashMapallows the existence of null keys and values, while a
Hashtabledoesn’t allow neither null keys, nor null values.
Hashtableis synchronized, while a
HashMapis not. Thus,
HashMapis preferred in single-threaded environments, while a
Hashtableis suitable for multi-threaded environments.
HashMapprovides its set of keys and a Java application can iterate over them. Thus, a
HashMapis fail-fast. On the other hand, a
Enumerationof its keys.
Hashtableclass is considered to be a legacy class.