Ans) Both collections implements Map. Both collections store value as key-value pairs. The key differences between the two are
- Hashmap is not synchronized in nature but hashtable is.
- Another difference is that iterator in the HashMap is fail-safe while the enumerator for the Hashtable isn't.
Fail-safe -if the Hashtable is structurally modified at any time after the iterator is created, in any way except through the iterator's own remove method, the iterator will throw a ConcurrentModificationException? - HashMap permits null values and only one null key, while Hashtable doesn't allow key or value as null.
No comments:
Post a Comment