Difference between HashMap and HashTable in Java

HashMap HashTable
No method in HashMap are synchronized. All methods in HashTable are synchronized.
HashMap is not theread safe because multiple thereads can operate on HashMap object simultaneously. HashTable is thread safe because at a time only one thread is allowed to operate on HashTable object.
Performance is high since theread are not required to wait. Performance is low since it increases the waiting time of a thread.
Null is allowed for both key and value. Null is not allowed for both key and value.
It is non legacy class. Introuduce in Java 1.2 It is legacy class. Introuduce in Java 1.0

Posted in collections and tagged , , .

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">