List与String互相转换,并以“,”分割

String转List

String nameArr = "张三, 李四, 王五";
List<String> alName = Arrays.asList(nameArr .split(","));

List转String

List<String> alName = Arrays.asList("张三, 李四, 王五");
String nameArr = alName.stream().collect(Collectors.joining(","));

你可能感兴趣的:(Java,stream,字符串,arraylist)