javacollectionshashmaphashtable

When should I use a Hashtable versus a HashMap


This is not a question about the differences between Hashtable and HashMap. I understand that a Hashtable object cannot accept null values for either key or value entries, that it is synchronized collection, and that it uses slightly less memory than a HashMap.

I'm wondering about the scenarios where it would be more appropriate to use a Hashtable instead of a HashMap.


Solution

  • This is not a question about the differences between Hashtable and HashMap

    Well it is really...

    I'm wondering about the scenarios where it would be more appropriate to use a Hashtable instead of a HashMap.

    Precisely when you want the differences between the two:

    I can't remember the last time I was in that situation, personally - I would say it's vanishingly rare to be appropriate to use Hashtable in modern Java code.