The following table shows the differences between the 'HashMap' and 'HashTable' in Java Technology.
HashMap | HashTable | |
1 | HashMap uses java.util.HashMap | Hashtable uses java.util.Hashtable |
2 | HashMap is not Synchronized. | HashTable is Synchronized. |
3 | HashMap permits null values as key and value. | HashTable do not permit null values as key and value. |
4 | HashMap is efficient than HashTable because HashMap is not Synchronized. | HashTable is less efficient because it is synchronized. |
5 | Iterator in the HashMap is fail-safe that means you can change the map while iterating. | Enumerator in the HashTable is not fail-safe. |
6 | HashMap can be synchronized as: Map m = Collections.synchronizeMap(hashMap); | No need of making it synchronized. |
Related Articles:
Difference between static class loading and dynamic class loading in java
Difference between Array and ArrayList in Java
Difference between Abstract Class and Interface in Java
Difference between String and StringBuffer/StringBuilder in Java
Difference between Csharp and Java
Difference between ArrayList and Vector in Java
Difference between Method Overloading and Method Overriding in Java
Difference between ‘is-a’ relationship and ‘has-a’ relationship in Java
Difference between C++ and Java
Difference between static class loading and dynamic class loading in java
Difference between Array and ArrayList in Java
Difference between Abstract Class and Interface in Java
Difference between String and StringBuffer/StringBuilder in Java
Difference between Csharp and Java
Difference between ArrayList and Vector in Java
Difference between Method Overloading and Method Overriding in Java
Difference between ‘is-a’ relationship and ‘has-a’ relationship in Java
Difference between C++ and Java