HashMap is a lightweight Implementation of Hashtable (non-thread-safe implementation). They all complete the Map interface. The main difference is that HashMap allows null key values ), because of non-thread security, the efficiency may be higher than that of Hashtable.
HashMap allows null as the key or value of an entry, whereas Hashtable does not.
HashMap removes the contains method of Hashtable and changes it to containsvalue and containsKey. The contains method is easy to misunderstand.
Hashtable inherits from the Dictionary class, while HashMap is an implementation of the Map interface introduced by Java1.2.
The biggest difference is that the Hashtable method is Synchronize, but HashMap is not. It is accessed in multiple threads.
In Hashtable, you do not need to implement synchronization for its own method, but HashMap must provide external synchronization for it.
The hash/rehash algorithms used by Hashtable and HashMap are roughly the same, so there is no big difference in performance.