What differences exist between HashMap and Hashtable ?
- A
HashMap
allows the existence of null keys and values,
Hashtable
doesn’t allow neither null keys, nor null values.
- A
Hashtable
is synchronized.
- while a
HashMap
is not.
-
HashMap
is preferred in single-threaded environments.
-
Hashtable
is suitable for multi-threaded environments.
- A
HashMap
provides its set of keys and a Java application can iterate over them.
Hashtable
provides an Enumeration
of its keys.
No comments:
Post a Comment