When should I use a Hashtable versus a HashMap

后端 未结 5 2288
野的像风
野的像风 2020-12-08 05:11

This is not a question about the differences between Hashtable and HashMap. I understand that a Hashtable object cannot accept

5条回答
  •  无人及你
    2020-12-08 05:50

    Knowing when to use one class or structure over another is essentially understanding the differences between the two, and deciding which one best suits the problem at hand based on those differences.

    I understand that a Hashtable object cannot accept null values

    So in the situation where you need to store null values, a Hashtable would not be appropriate.

    Also, in a Hashtable, enumeration is not fail-safe. So if you need to be able to change the content of the structure while enumerating, a Hashtable would be more appropriate.

提交回复
热议问题