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 are the differences between heap and stack memory in java?

541


What are thread local variables?

556


What is data type in computer?

521


What is a lightweight component?

598


What will be the initial value of an object reference which is defined as an instance variable?

646






What is the role of garbage collector in java?

495


Explain covariant method overriding in java.

544


What does java final mean?

522


What is bubble sorting in java?

596


What is the purpose of the System class?

583


What is the symbol for average?

521


What is qms certification?

523


Explain the scope or life time of class variables or static variables?

521


How do you compare two objects?

524


Can you override private or static method in java?

555