What is the main advantage of using Hashtablecompared to HashMap. Because the Hashtablemain advantage is synchronization. Now the card can also sync with synchronizedMap().
Hashtable
HashMap
synchronizedMap()
Map m = Collections.synchronizedMap(hashMap);
Hashtableexisted before collections, so it is saved mainly for backward compatibility. Use instead ConcurrentHashMap.
ConcurrentHashMap
Please note that there is a small semantic difference - it Hashtabledoes not allow null values, but HashMapallows null values and a null key.
HashTable . , HashTable , HashMap - . , , , HashTable , .
HashTable
, , HashTable , - , - , , :
if(key does not exist) add key
, , . .
, HashTable ...