difference between hashmap and hashtable?

5 views
Skip to first unread message

amy

unread,
Dec 14, 2011, 12:22:04 PM12/14/11
to aksforjava
difference between hashmap and hashtable?

pappu prasad

unread,
Jan 12, 2012, 5:53:14 AM1/12/12
to aksforjava
HashMap object are not synchronized by default but hashtable objects
are synchronized by default

amy

unread,
Oct 12, 2012, 9:05:39 AM10/12/12
to aksfo...@googlegroups.com
  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.
Reply all
Reply to author
Forward
0 new messages