public void test() {
//字符串转list<String>
String str = "测试1,测试2,测试3,测试4";
//此处为了将字符串中的空格去除做了一下操作
List<String> list= Arrays.asList(str .split(",")).stream().map(s -> (s.trim())).collect(Collectors.toList());
//list<String>转字符串(以逗号隔开)
System.out.println(String.join(",", list));
}
参考:https://blog.csdn.net/sinat_27535209/article/details/80595404
如有雷同纯属巧合