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 package has light weight components?
What are static initalizers in java ?
What is the purpose of void?
What is difference between java and java ee?
How do you override a variable in java?
what is synchronization? : Java thread
Name the components that are termed to be Heavy-weight component but available in Light-weight components?
What happens if we don’t override run method ?
What is the difference between ArrayList and Vector? which one is better in Java
What is stringreader?
Why declare Main() method as a static in java ?
Does java linked list allow duplicates?
What are the core java topics?
What is the indent key?
What is static class