Satheesh Reddy
What is the difference between Hashtable and hashmap in Java
By Satheesh Reddy in Java on Jan 21 2014
  • amit gupta
    Jan, 2016 23

    Legacy HashMap was introduced in JDK 1.2 and extends AbstractMap class whereas Hashtable is a legacy class which initially was not part of collection framework. Later from JDK 1.2 it became part of Collection framework and implemented Map interface. Dictionary is the super class of Hashtable class.SynchronizedHashMap is not synchronized whereas Hashtable is synchronized. But you can explicitly synchronize HashMap. Hence, Hashtable is thread-safe whereas HashMap is not thread-safe.Keys & ValuesHashtable does not allow null keys and null values whereas HashMap allows to store one null key and any number of null values.Read full article at Difference between Hashmap and Hashtable in Java

    • 0
  • Yashwanth Muthineni
    Jul, 2015 13

    http://javahungry.blogspot.com/2014/03/hashmap-vs-hashtable-difference-with-example-java-interview-questions.htmlgo through the above link..it will be very useful

    • 0
  • Munesh Sharma
    Apr, 2014 15

    There are several differences between HashMap and Hashtable in Java:Hashtable is synchronized, whereas HashMap is not. This makes HashMap better for non-threaded applications, as unsynchronized Objects typically perform better than synchronized ones. Hashtable does not allow null keys or values. HashMap allows one null key and any number of null values. 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.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS