There are several differences between HashMap and Hashtable in Java:
Hashtable
does not allow null keys or values.HashMap
allows one null key and any number ofnull
values.- One of HashMap's subclasses is LinkedHashMap, so in the event that you'd want predictable iteration order (which is insertion order by default), you could easily swap out the
HashMap
for aLinkedHashMap
. This wouldn't be as easy if you were usingHashtable
.
Since synchronization is not an issue for you, I'd recommend
HashMap
. If synchronization becomes an issue, you may also look at ConcurrentHashMap.
Comments
Post a Comment