Saturday, 19 July 2014

Difference between HashMap and HashTable

  1. Main Difference is HashMap is Non-synchronized, where as HashTable is synchronized. Which means Hash table is thread safe, so in multi threaded environment user no need to worry while performing operations on HashTable. But HashMap is not synchronized, so it is users responsibility to synchronize the things in Multi threaded Environment.
  2. HashMap allows null valuses as key, but HashTable won't allow null values.
  3. Since Synchronization is costliest operation, HashTable is slower than HashMap in single threaded Environment.


                                                             Home

No comments:

Post a Comment