Like Us On Facebook

Follow Us On Twitter

Drop Down Menu

Friday, 10 March 2017

Difference Between Hashmap and Hashtable Java

There are several notable differences between Hashmap and Hashtable in Java, such as:

1. Hashmap has one sub-type -> LinkedHashMap. It is used if you want insertion order by default, in which case you can easily swap a Hashmap for a LinkedHashMap, which wouldn't be possible in case of a Hashtable.
2. Hashmap allows a single NULL key and any number of NULL values, whereas Hashtable does not allow NULL KEYS OR VALUES.
3. Hashmap is not synchronized, where Hashtable is. This makes Hashtable better for threaded applications as synchronized objects usually perform better than unsynchronized ones

However, there're a few more differences between these two, and have been summarized below:
Difference Between Hashmap and Hashtable Java | Coding Bot