You use the same approach by simply passing the converted array to the Set constructor :
Set<String> items = new HashSet<String>(Arrays.asList(comment.split(", ")));
Further simplification is impossible without third-party libraries, but there are no drawbacks, since Arrays.asListO (1) is executed in constant time.
source
share