Reputation: 147
I'm trying to use Set.of()
to create a set of string. Here is my import and code. I don't know why it always reports cannot find symbol:
import java.util.Set;
Set<String> existedFieldsValueList = Set.of("field1", "field2");
Here is the error log
[javac] Set<String> existedFieldsValueList = Set.of("field1", "field2");
[javac] ^
[javac] symbol: method of(String,String)
[javac] location: interface Set
Did I miss anything?
Upvotes: 1
Views: 2708
Reputation: 312344
This method was introduced in JDK 9. From the error message, it looks like you're using an older JDK. Upgrade to a newer one and you should be fine.
Upvotes: 4