What is difference between hash mapping and hash table?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / murali.s
hashtable is a Synchronized.
hashmap is not a Synchrobnized.
Hashtable doesn,t accept null key,values
Hashmap accept null key,values
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / sandya
Yes... I agree with u khalid.
can u send the examples in CFW.
Thanks in Advance.
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / 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 |
what is synchronization? : Java thread
What is the syntax and characteristics of a lambda expression?
Give a brief description of java socket programming?
Is java written in c?
What is the technique adopted to create an immutable class?
What is the use of put method?
What is synchronization and why is it important in java programming?
What is stack class in java?
which method is used to know the status of the Thread?
How many times garbage collector will invoke an object?s finalize() method?
Are the equals() and hashCode() protected methods of object class?
what is the J2EE BluPrints?