HashMap
|
HashTable
|
1) HashMap is non synchronized. It is not-thread safe and can't be shared between many threads without proper synchronization code.
|
Hashtable is synchronized. It is thread-safe and can be shared with many threads.
|
2) HashMapallows one null key and multiple null values.
|
Hashtabledoesn't allow any null key or value.
|
4) HashMap is fast.
|
Hashtable is slow.
|
5) We can make the HashMap as synchronized by calling this code
Map m = Collections.synchronizedMap(hashMap); |
Hashtable is internally synchronized and can't be unsynchronized.
|
Wednesday, 9 September 2015
Java - Differences between HashMap and Hashtable
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment