Why I can not use Hashtable in Java?


  • 0
    S

    I noticed this problem on other tasks also. When I try to compile the following snipet:

    Hashtable<Integer, Integer> ht = new Hashtable<Integer, Integer>();
    

    I got the following error message:

    error: cannot find symbol: class Hashtable

    Why?


  • 2
    V

    The class you're looking for is HashMap.


  • 0
    E

    I don't think leetcode support all the library of Java. There is a time that I tried to use StringTokenizer and end up with the same error message as yours. In this case, just use the HashMap<>();


  • 0
    H

    You can include any missing library using import statement in your code

    import java.util.Hashtable;
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.