Replacement for obsolete Hashtable class in Java

后端 未结 6 1690
夕颜
夕颜 2021-01-01 17:51

When I tried to use the hashtable class, Netbeans gave me an error saying:

While still supported, these classes were made obsolete by the JDK1.2 colle

6条回答
  •  暖寄归人
    2021-01-01 18:09

    You should use HashMap, but it is not designed for concurrent environments, where you may use ConcurrentHashMap.

    OR

    Map myMap = Collections.synchronizedMap(/*any map instance*/);
    

提交回复
热议问题