Hashmap vs Hashtable
- HashMap is non-synchronized. It is not thread-safe and can’t be shared between many threads without proper synchronization code whereas Hashtable is synchronized. It is thread-safe and can be shared with many threads.
- HashMap allows one null key and multiple null values whereas Hashtable doesn’t allow any null key or value.
- HashMap is generally preferred over HashTable if thread synchronization is not needed.
Ref:
- https://www.geeksforgeeks.org/differences-between-hashmap-and-hashtable-in-java/
- https://www.javatpoint.com/java-map
No comments:
Post a Comment