Hi,
What is the difference between Hash Map and Hash Table in Java ?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Oct 21, 2011, 7:45 PM EDT
1.Hashtable is synchronized while access to the HashMap is not synchronized.
2.HashMap allows null values as Key, while Hashtable doesn't.
3.Iterator in a HashMap is fail-safe(Fail-safe is relevant from the context of iterators.If an iterator has been created on a collection object and some other thread tries to modify the collection object "structurally",a concurrent modification exception will be thrown) while the enumerator of HashTable is not.
Thanks
Prabhu RajaRank #861 · 2.6K reputationPosted Oct 21, 2011, 8:04 PM EDT
Hope it will useful for you.
HashMap
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 21, 2011, 6:41 PM EDT
1. Hashtable is synchronized and whereas HashMap is not.
2. Hashtable does not allow null keys or values. HashMap allows one null key and any number of null values.
Please do not forget to mark "Accepted Answer".