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 ? | 0 Yes | 5 No |
Post New Answer View All Answers
What is unmodifiable list in java?
What is callablestatement? How you can call stored procedure to pass in parameter?
What is sorting in java?
Can we have more than one package statement in source file ?
What is nullpointerexception in java?
Is int primitive data type?
what do you understand by synchronization? : Java thread
can rmi and corba based applications interact ?
What is better - 'bit-shift a value' or 'multiply by 2'?
Difference between static and dynamic class loading.
Explain the difference between collection api and stream api in java8?
What does main method?
Is alive and join method in java?
Why Java doesn’t support multiple inheritance?
What does bitwise or mean?