前言
JDK9中的Set.of()创建是不能有重复元素的,否则会报错
Set.of()使用注意
csharp
public class Set1Demo {
static void main() {
Set<Integer> set = Set.of(1, 1, 2, 3, 4, 5);
System.out.println(set);
}
}
输出结果为

总结
JDK9中的Set.of()创建是不能有重复元素的,否则会报错