- List<String> testList = new ArrayList<>();
- testList.add("test1");
- testList.add("test2");
- testList.add("test3");
-
- String newStr = testList.stream().collect(Collectors.joining(","));
- System.out.println(newStr);
- String str = "aa,bb,cc";
- String[] strList = str.split(",");
-
- for(int i=0;i<strList.length;i++){
- System.out.println(strList[i]);
- }
- String str = "a,b,c";
- List<String> resultList = Arrays.asList(str.split(","));
- System.out.println(resultList);
- String str="ab cd efg";
- char[] a=str.toCharArray();
- System.out.println(Arrays.toString(a));
参考:java将list转为逗号隔开字符串_51CTO博客_list转字符串逗号隔开