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
Which is faster set or list in java?
Difference between comparator and comparable in java?
Write a java program that prints all the values given at command-line.
Explain 5 io best practices?
Is hashset ordered java?
Can we sort set in java?
Which containers use a flowlayout as their default layout in java programming?
Differences between C and Java?
What is an example of a constant variable?
What is lambda expression in java?
What class allows you to read objects directly from a stream?
Can we overload destructor in java?
Is there any limitation of using inheritance?
How to write custom exception in java?
Does set allows null in java?