Example & Tutorial understanding programming in easy ways.

What is difference between HashMap and HashTable?

Following are some difference as :

                                   HashMap                         HashTable
1 Hashmap is not synchronized in nature .
 
1 Hashtable is synchronised.
 
2 iterator in the HashMap is fail-safe .
Fail-safe - “if the Hashtable is structurally modified at any time after the iterator is created, in any way except through the iterator's own remove method, the iterator will throw a ConcurrentModificationException”
 
2 while for the Hashtable is not.
 
3 HashMap permits null values and only one null key.
 
3 while Hashtable doesn't allow key or value as null.
 
4 HashMap use iterator.
 
4 Hashtable use enumeration.
 
5 HashMap is faster. 5 Hashtable is slower.

Read More →