What is difference between hash mapping and hash table?

Answers were Sorted based on User's Feedback



What is difference between hash mapping and hash table?..

Answer / khalid

Both provide key-value access to data. The Hashtable is one
of the original collection classes in Java. HashMap is part
of the new Collections Framework, added with Java 2, v1.2.
The key difference between the two is that access to the
Hashtable is synchronized on the table while access to the
HashMap isn't. You can add it, but it isn't there by
default.

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.

And, a third difference is that HashMap permits null values
in it, while Hashtable doesn't.

For new code, I would tend to always use HashMap.

Is This Answer Correct ?    11 Yes 1 No

What is difference between hash mapping and hash table?..

Answer / murali.s

hashtable is a Synchronized.
hashmap is not a Synchrobnized.
Hashtable doesn,t accept null key,values
Hashmap accept null key,values

Is This Answer Correct ?    4 Yes 0 No

What is difference between hash mapping and hash table?..

Answer / ravi jain

Khalid's answer is right but it has one mistake i.e.

in second point HashMap is also fail-fast...

Is This Answer Correct ?    1 Yes 0 No

What is difference between hash mapping and hash table?..

Answer / sandya

Yes... I agree with u khalid.
can u send the examples in CFW.
Thanks in Advance.

Is This Answer Correct ?    0 Yes 1 No

What is difference between hash mapping and hash table?..

Answer / khalid

Both provide key-value access to data. The Hashtable is one
of the original collection classes in Java. HashMap is part
of the new Collections Framework, added with Java 2, v1.2.
The key difference between the two is that access to the
Hashtable is synchronized on the table while access to the
HashMap isn't. You can add it, but it isn't there by
default.

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.

And, a third difference is that HashMap permits null values
in it, while Hashtable doesn't.

For new code, I would tend to always use HashMap.

Is This Answer Correct ?    0 Yes 5 No

Post New Answer

More Core Java Interview Questions

What is deserialization?

0 Answers  


After compilation of java program we'll get .class code. If it's generated in OS Windows XP will it work on OS Linux? If yes why? If no why?

5 Answers   Aricent,


Why are data types important?

0 Answers  


what are the methods in object?

0 Answers   IBS,


Explain about procedural programming language or structured programming language and its features?

0 Answers  


What does string mean in java?

0 Answers  


Is there any sort function in java?

0 Answers  


How do you compare objects in java?

0 Answers  


What is meant by Java ?

2 Answers   CMC, Infosys,


What is a variable in java?

0 Answers  


How to display names of all components in a Container?

0 Answers   Microsoft, Wipro,


Why put method is used?

0 Answers  


Categories