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
Class c implements interface I containing method m1 and m2 declarations. Class c has provided implementation for method m2. Can I create an object of class c?
What is meant by polymorphism?
Can we catch more than one exception in single catch block?
What is tree node in java?
What is difference between Heap and Stack Memory?
What do you understand by weak reference?
how is final different from finally and finalize in java?
What does += mean in java?
What is the use of coding?
How to calculate the length of a singly linked list in java?
23. Storage space in java is of the form Stack Queue Heap List 24. What is java code embedded in a web page known as Applets Servlets scriptlets snippets 25. Which of the following attributes are compulsory with an
What is the difference between state-based unit testing and interaction-based unit testing?
How do you replace a string in java?
What is memory leak and how does java handle it?
How do you compare two objects?