What is the difference between HashTable and HashMap?

This question is related to Oracle Interview

Showing Answers 1 - 10 of 10 Answers

Varsha Sharma

  • Jun 14th, 2005
 

Hashtable is synchronized means it's therad safe ,where as hashmap is not . 
and hash table can't store null value hashmap can store null values.

  Was this answer useful?  Yes

kumpsath

  • Sep 19th, 2009
 

Hashtable is synchronized means it's therad safe where as hashmap is not and hash table can't store null value hashmap can store null values. HashTable is thread safe is because, it makes lock in it when it executes get() or put() methods. It is good one when you use the data in an multi-threading application. You may try use hashmap inside synchronized block.

  Was this answer useful?  Yes

Hashtable does not allow null values or null keys, whereas hash map allows null keys and null values. Hashtable is synchronzied whareas hashmap is not synchronized. In case of single thread using hashmap is faster than the hashtable. In case of multiple thereads, using hashtable is advisable.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions