As @AndyTurner said in a comment:
fields[1]
is aString
, not aHashSet<String>
. You can build the latter usingnew HashSet<>(Arrays.asList(fields[1]))
.
But there are other issues with this snippet too. It would be better to rewrite like this, pay close attention to every little detail that I changed:
private Map<String, Set<String>> userBusiness = new HashMap<>();
...
String[] fields = output.split("\t");
userBusiness.put(fields[0], new HashSet<>(Collections.singletonList(fields[1])));
2
solved Adding an element into a HashSet inside a HashMap Java [closed]