HashMap and HashTable both implements Map interface but their are some difference between HashMap and HashTable.
1. HashMap is not synchronized whereas HashTable is synchronized.
2. HashMap allows one null key and any number of null values but HashTable does not allow null keys or values.
3. Iterator in HashMap is fail fast but Enumeration in HashTable is not fail fast.
2. HashMap allows one null key and any number of null values but HashTable does not allow null keys or values.
3. Iterator in HashMap is fail fast but Enumeration in HashTable is not fail fast.
Parameter | Hashmap | Hashtable |
---|---|---|
Synchronized | Not Syncronized | Syncronized |
Null key and Value | Allows one null key and any number of null values | Not allow null keys or values |
Fail fast | Iterator in Hashmap is fail fast | Enumeration in Hashtable is not fail fast |
ThreadSafe | No | Yes |
Extends | Extends AbstractMap class | Extends Dictionary class |
Performance | Faster then Hashtable | Slower then Hashmap |
EmoticonEmoticon