What are the differences between a HashMap and a Hashtable in Java?
Which is more efficient for non-threaded applications?
1.Hashmap
and HashTable
both store key and value.
2.Hashmap
can store one key as null
. Hashtable
can't store null
.
3.HashMap
is not synchronized but Hashtable
is synchronized.
4.HashMap
can be synchronized with Collection.SyncronizedMap(map)
Map hashmap = new HashMap();
Map map = Collections.SyncronizedMap(hashmap);