What is the difference between HashMap and HashTable?

Hash Map
Hash Table
Hash Map is not synchronized
Hash Table is synchronized
In case of single thread, Hash Map is faster than Hash Table
In case of multiple threads Hash Table is advisable, with single thread model it becomes slow
Hash Map allows null keys and null values
Hash table does not allow null keys or null values
Iterator in Hash Map is fail-fast means it will produce exception if concurrent updates made to Hash Map
Enumeration for Hash table is not fail-fast means even if concurrent updates are done to Hash Table, Enum will not produce any incorrect results

No comments:

Post a Comment