What is the difference between a HashMap and a Hashtable in Java?

There are several differences between HashMap and Hashtable in Java:

  1. Hashtable is synchronized, whereas HashMap is not. This makes HashMap better for non-threaded applications, as unsynchronized Objects typically perform better than synchronized ones.
  2. Hashtable does not allow null keys or values. HashMap allows one null key and any number of null values.
  3. One of HashMap’s subclasses is LinkedHashMap, so in the event that you’d want predictable iteration order (which is insertion order by default), you could easily swap out the HashMap for a LinkedHashMap. This wouldn’t be as easy if you were using Hashtable.

 

source

http://stackoverflow.com/questions/40471/differences-between-hashmap-and-hashtable

One thought on “What is the difference between a HashMap and a Hashtable in Java?

  1. aluminumextrusionss.com January 15, 2014 at 9:01 am Reply

    If compared with other metals like Ag or Cu, it’s weight
    is one third of them. The first to cultivatee and develop strategic Hunan
    gain an advantage in new industries. Providing
    solutions for partners that enables corporations to startup successfully in a large
    and geographically diverse market.

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

%d bloggers like this: