What is difference between hash mapping and hash table?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Name some classes present in java.util.regex package.

608


What if the main() method is declared as private? What happens when the static modifier is removed from the signature of the main() method?

691


What is boolean data type in java?

570


Can we convert integer to string in java?

598


Can list contain null in java?

629






Can an unreferenced object be referenced again?

767


What is a package in java? List down various advantages of packages.

761


What is OOP Language?

631


What is the generic class?

533


What is the difference between this() and super() in java?

543


What are the drawbacks for singleton class?

520


How do you convert bytes to character in java?

539


Can we able to pass objects as an arguments in java?

535


How is hashcode calculated in java?

506


State the significance of public, private, protected class?

655