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
Name some classes present in java.util.regex package.
What if the main() method is declared as private? What happens when the static modifier is removed from the signature of the main() method?
What is boolean data type in java?
Can we convert integer to string in java?
Can list contain null in java?
Can an unreferenced object be referenced again?
What is a package in java? List down various advantages of packages.
What is OOP Language?
What is the generic class?
What is the difference between this() and super() in java?
What are the drawbacks for singleton class?
How do you convert bytes to character in java?
Can we able to pass objects as an arguments in java?
How is hashcode calculated in java?
State the significance of public, private, protected class?