HashMap vs HashTable - JAVA
There are several differences between HashMap and Hashtable in Java:
Hashtabledoes not allownullkeys or values.HashMapallows onenullkey and any number ofnullvalues.- 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 theHashMapfor aLinkedHashMap. This wouldn't be as easy if you were usingHashtable.
Note on Some Important Terms :
Synchronized means only one thread can modify a hash table at one point of time. Basically, it means that any thread before performing an update on a hashtable will have to acquire a lock on the object while others will wait for the lock to be released.
Comments
Post a Comment