what is the difference between HashMap and Hashtable

Answer Posted / jyotsna gupta

1. Hashtable is synchronized where as hashmap is not.
2. Hashmap can contains null values as the keys and as well as values.But Hashtable dose not allow null values as keys and values.
3. Another difference is that iterator in the HashMap is fail-safe while the enumerator for the Hashtable isn't. If you change the map while iterating, you'll know.
4. Hashmap is faster than Hashtable.

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between quicksort & mergesort? When should they be used? What is their running time?

846


What are advantages of using Java?s layout managers than windowing systems?

2091


What is constructor and its types?

793


What Is Query Throttling in java?

785


What is string length in java?

706


What is difference between jdk,jre and jvm?

808


What is the use of join method?

802


Can we convert stringbuffer to string?

771


Why multiple inheritance is not supported by java?

735


What does arrays sort do in java?

758


Are true and false keywords?

795


In the below example, how many string objects are created?

784


How to display all the prime numbers between 1 and 100

722


What is final method?

822


What is a protected void?

706