Advertisements

Aatul Palandurkar

Posts Tagged ‘Difference between HashMap and HashTable

Objectives:

  • 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.

Advertisements

Advertisements

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 14,098 other followers

Tweets

YouTube

Archives

Advertisements
%d bloggers like this: