Reputation: 33
when i'm trying to run this code:
Set<Set<Integer>> s1 = Set.of(Set.of(), Set.of(1));
i'm getting this error:
The method of() is undefined for the type Set
The method of(int) is undefined for the type Set
I'm using Java 8. What is wrong? :/
Upvotes: 3
Views: 7303
Reputation: 147164
These methods were introduced in Java SE 9. See the @since
in the source code on the API docs. You'll need to upgrade to a current version of Java or use something else, such as new HashSet<>(Arrays.asList(fred, jim, sheila))
.
Upvotes: 5