Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I've been staring at the screen the last 5 minutes and can't seem to figure out what I'm doing wrong:
- class Example {
- private final Set<String> values;
- public Example(String... values) {
- values = new HashSet<String>(Arrays.asList(values));
- }
- }
- I'm surprised why the `String[]` cannot be converted to `List<String>` to initialize the `HashSet<String>` with it.
- I'm getting the build error:
- > incompatible types: java.util.HashSet<java.lang.String> cannot be converted to java.lang.String[]
- What's wrong with my assignment?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement