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

How do you create a reference in java?

735


When a thread is executing synchronized methods , then is it possible to execute other synchronized methods simultaneously by other threads?

823


How will you serialize a singleton class without violating singleton pattern?

1760


Is math an abstract class in java?

747


What are recursive functions? Give some examples?

890


What is the collections api?

808


What are exception handling keywords in java?

834


Why arraylist is used in java?

794


Is linkedlist thread safe in java?

801


What is a conditional statement explain with example?

789


What is variable explain?

762


How many bits is a 64 bit byte?

784


How does system arraycopy work in java?

872


What is the purpose of finalization in java programming?

823


What access modifiers can be used for methods?

856