1. Prepare a comma separated string
String str = "小张,小王,小李,小赵";
2. Convert the comma-separated string to a set (it will be converted to an array before converting to a set)
List<String> strList1 = Arrays.asList(str.split(","));
List<String> strList2 = Arrays.stream(str.split(",")).collect(Collectors.toList());
List<Integer> intList = Arrays.stream(str.split(",")).map(Integer::parseInt).collect(Collectors.toList());
List<String> strList3= Splitter.on(",").trimResults().splitToList(str);
List<String> strList4= Arrays.asList(StringUtils.split(str,","));
List<String> strList5 =Arrays.asList(StringUtils.commaDelimitedListToStringArray(str));
3. Convert collection to comma separated string
str = String.join(",", strList1);
str = StringUtils.join(strList1.toArray(), ",");
str = Joiner.on(",").join(strList1);
StringJoiner sj = new StringJoiner(",");
strList1.forEach(e -> sj.add(String.valueOf(e)));
StringJoiner sj2 = new StringJoiner(",", "START_", "_END");
strList1.forEach(e -> sj2.add(String.valueOf(e)));
str = strList1.stream().collect(Collectors.joining(","));
str = strList1.stream().map(e -> {
if (e != null) return e.toUpperCase();
else return "null";
}).collect(Collectors.joining(",", "START_", "_END"));
str = StringUtils.collectionToDelimitedString(strList1,",");
4. Convert array to comma separated string
String [] arr = (String[])strList1.toArray();
str = StringUtils.join(arr, ",");
ArrayUtils.toString(arr, ",");