Java 类型集的()方法未定义

Java 类型集的()方法未定义,java,compiler-errors,set,Java,Compiler Errors,Set,当我尝试运行此代码时: Set<Set<Integer>> s1 = Set.of(Set.of(), Set.of(1)); 我正在使用Java8。怎么了/ 这些方法是在JavaSE9中介绍的。请参阅API文档上源代码中的@since。您需要升级到Java的当前版本或使用其他东西,例如新的HashSet(Arrays.asList(fred,jim,sheila))它们是在Java 9中添加的。看。 The method of() is undefined for t

当我尝试运行此代码时:

Set<Set<Integer>> s1 = Set.of(Set.of(), Set.of(1));

我正在使用Java8。怎么了/

这些方法是在JavaSE9中介绍的。请参阅API文档上源代码中的
@since
。您需要升级到Java的当前版本或使用其他东西,例如
新的HashSet(Arrays.asList(fred,jim,sheila))

它们是在Java 9中添加的。看。
The method of() is undefined for the type Set
The method of(int) is undefined for the type Set