6 Dec 2017

what is difference between HashMap and Hashtable ?

HashMap
Hashtable
No Method Present in HashMap is Synchronized.
Every Method Present in Hashtable is Synchronized.
At a Time Multiple Threads are allowed to Operate on HashMap Object simultaneously and Hence it is Not Thread Safe.
At a Time Only One Thread is allowed to Operate on the Hashtable Object and Hence it is Thread Safe.
Relatively Performance is High.
Relatively Performance is Low.
null is allowed for Both Keys and Values.
null is Not allowed for Both Keys and Values. Otherwise we will get NPE.
Introduced in 1.2 Version and it is Non – Legacy.
Introduced in 1.0 Version and it is Legacy.