Cannot instantiate the type Set

前端 未结 3 2073
春和景丽
春和景丽 2021-01-03 18:51

I am trying to create a Set of Strings which is filled with the keys from a Hashtable so a for-each loop can iterate through the Set and put defaults in a Hashtable. I am st

3条回答
  •  醉酒成梦
    2021-01-03 19:06

    Set is not a class, it is an interface.

    So basically you can instantiate only class implementing Set (HashSet, LinkedHashSet orTreeSet)

    For instance :

    Set mySet = new HashSet();
    

提交回复
热议问题