Advertisements

Aatul Palandurkar

7 differences between HashMap and HashTable

Posted on: June 7, 2015

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Advertisements

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

Join 8,305 other followers

Tweets

%d bloggers like this: