Replacement for obsolete Hashtable class in Java

后端 未结 6 1685
夕颜
夕颜 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:35

    A better replacement for Hashtable is HashMap.

    As for being obsolete, I have no reference to it, but the Javadoc states:

    As of the Java 2 platform v1.2, this class was retrofitted to implement the Map interface, making it a member of the Java Collections Framework.

    Hashtable is synchronized unlike HashMap.

提交回复
热议问题