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
What is string subsequence method?
What is the length of a string?
Write a java program that prints all the values given at command-line.
how to know the total memory occupied by the objects in the ArrayList(Array list may contain duplicate objects)
Is an object null?
Is ruby built on java?
What is function and its uses?
What are the elements of java?
What is a two-pass assembler?
what is the use of bean managed and container managed with example?
What causes memory leaks in java?
Which number is denoted by leading zero in java?
State some situations where exceptions may arise in java?
What does the @override annotation do?
What are alternatives to java serialization?