Difference Hashmap vs Hashtable in java
In this java interview questions, we will learn about:
hashmap vs hashtable in java
Hashmap vs Hashtable in java
Difference between HashMap and HashTable is highlighted below based on the following parameters:
HashMap is not synchronized in nature.
HashTable is synchronized in nature.
HashMap can be traversed by using an iterator.
HashTable can be traversed by using an iterator or enumerator.
HashMap allows only one null key and any number of null values.
HashTable doesn't allow key or value to be null.
fail-fast nature of iterator or enumerator
Iterator in HashMap is fail-fast.
Enumerator in HashTable is not fail-fast.
HashMap is faster in terms of performance.
HashTable is slower in comparision to HashMap in terms of performance.
Reason: Since HashTable is synchronized in nature so it doesn't allow multi-threading operation on a particular resource at a time thus turning out to be slower than HashMap which is non-synchronized by nature.
Would you like to see your article here on tutorialsinhand.
program by tutorialsinhand.com
About the Author
I am editor in chief at tutorialsinhand.com responsible for managing, reviewing and sending articles/contents for final approval to get published. Connect with me@https://www.linkedin.com/in/sonu-pandit-a77b471ab/. Join write4us program & share your skill
Page Views :
Published Date :