Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


what is the difference between HashMap and Hashtable

Answers were Sorted based on User's Feedback



what is the difference between HashMap and Hashtable..

Answer / sarithareddy

Hashmap work as like as Hashtable but hashtable is
synchronised hash map was not sychronized
hashtable does not allow null values
hashmap allows null values

Is This Answer Correct ?    123 Yes 16 No

what is the difference between HashMap and Hashtable..

Answer / chandan phukan

Two main differences between Hastable and HashMap are

1. Hashtable is synchronised but HashMap is not.
2. Hashtable does not allow "null" key but HashMap allows
"null" Key.

However one point to remember is that only one "null" key is
allowed in HashMap but multiple "null" values are allowed in
HashMap.

Is This Answer Correct ?    75 Yes 9 No

what is the difference between HashMap and Hashtable..

Answer / arun rajesh

The HashMap class is roughly equivalent to Hashtable,
except that it is unsynchronized and permits nulls.
(HashMap allows null values as key and value whereas
Hashtable doesnt allow).

HashMap does not guarantee that the order of the map will
remain constant over time. HashMap is unsynchronized and
Hashtable is synchronized.

Is This Answer Correct ?    54 Yes 12 No

what is the difference between HashMap and Hashtable..

Answer / knowledge_finder

1. HashMap allows null values for key and value whereas
Hashtable doesnt allow.
2. HashMap does not guarantee that the order of the map will
remain constant over time. 3. HashMap is non synchronized
where as Hashtable is synchronized.
4. HashTable is an Old java class but Hashmap is a new java
class in java 2.
5. In HashTable you can change the iteration but in the case
of HashMap you can change the iteration but you will get a
java.util.ConcurrentModificationException.

Is This Answer Correct ?    35 Yes 5 No

what is the difference between HashMap and Hashtable..

Answer / suresh

HashMap hm=new HashMap();
hm.put("1","11");
hm.put("2","22");
hm.put("3","33");
hm.put("4","242");
hm.put(null,null);
hm.put(null,null);
HashMap also allow more null values

Is This Answer Correct ?    24 Yes 13 No

what is the difference between HashMap and Hashtable..

Answer / regalla naresh reddy

Hash Table is a legacy Class Whereas HashMap belongs to the
collections package.

HashMap allows null key and values..but it allows only one
null key and multiple null values...Whereas the HashTable
wont allow the null key and values..

Is This Answer Correct ?    15 Yes 6 No

what is the difference between HashMap and Hashtable..

Answer / prabhat ranjan

You all said that HashMap allows 1 null key and mulitple
null values but why ? What was the basic idea behind it
making such feature by JAVA bulider ?

Is This Answer Correct ?    12 Yes 4 No

what is the difference between HashMap and Hashtable..

Answer / venkatesh marni

in the HashMap & Hashtable wen ever key values are Same then
it maps only to the value which is mapped at last.
REFER to the ANS.9 above we can access only one value.

but Hashtable is Synchronized one and it wont stores any
null values.

Is This Answer Correct ?    2 Yes 0 No

what is the difference between HashMap and Hashtable..

Answer / green

HashTable is a Legacy Class,where as HashMap is not.
HashTable is Syncronized,where as HashMap is not.
HashTable does not allow any null keys nad values, HashMap
allows one null key and 'n' number null values.
comparatively HashMap is faster then HashTable

Is This Answer Correct ?    3 Yes 1 No

what is the difference between HashMap and Hashtable..

Answer / ashad

Hash Table is a legacy Class Whereas HashMap belongs to the
collections package.

HashMap allows null key and values..but it allows only one
null key and multiple null values...Whereas the HashTable
wont allow the null key and values..


HashMap allows only one null key, basic idea behind it is
that key can have unique value only if one null is assigned
to a key next null will be duplicate.

Is This Answer Correct ?    10 Yes 9 No

Post New Answer



More Core Java Interview Questions

Why do people says “java is robust”?

0 Answers  


Name the runtime exceptions that occurs frequently?

4 Answers  


What are the restrictions that are applied to the java static methods?

0 Answers  


What is a line break example?

0 Answers  


How to Sort Strings which are given in List and display in ascending order without using java api.

1 Answers   LIC,






How do you define a parameter?

0 Answers  


What are event-delegation model and event-inheritance model? Which is best?

1 Answers  


What is an arraylist in java?

0 Answers  


What are features of java?

0 Answers  


How are Java source code files named?

3 Answers  


How can a gui component handle its own events in java programming?

0 Answers  


How do you remove duplicates in java?

0 Answers  






Categories