Archive for June 2015
- What is HashMap?
- What is HashMap in Java?
- What is HashTable?
- What is HashTable in Java?
- What are the differences between HashMap and HashTable?
- What are the differences between HashMap and HashTable in Java?
HashMap vs HashTable
1. HashMap is non-synchronized. HashTable is synchronized.
2. HashMap is not thread safe. HashTable is thread safe.
3. HashMap allows one null key and any number of null values while HashTable do not allow null keys and null values in HashTable Object.
4. HashMap object values are iterated using iterator. HashTable is only class other than Vector class which uses enumerator to iterate values of HashTable object.
5. The iterator in HashMap is fail-fast iterator while enumerator for HashTable is not.
6. HashMap is much faster and uses less memory than HashTable.
7. HashMap is subclass of AbstractMap class. HashTable is subclass of Dictionary class which is obsolete in 1.7 and not in use anymore.