java - Differences between HashMap and Hashtable? -
what differences between hashmap
, hashtable
in java?
which more efficient non-threaded applications?
there several differences between hashmap , hashtable in java:
hashtable
synchronized, whereashashmap
not. makeshashmap
better non-threaded applications, unsynchronized objects typically perform better synchronized ones.hashtable
not allownull
keys or values.hashmap
allows 1null
key , number ofnull
values.one of hashmap's subclasses
linkedhashmap
, in event you'd want predictable iteration order (which insertion order default), swap outhashmap
linkedhashmap
. wouldn't easy if usinghashtable
.
since synchronization not issue you, i'd recommend hashmap
. if synchronization becomes issue, may @ concurrenthashmap
.
Comments
Post a Comment