certNameList = "certNameList": "消防设施工程专业承包二级,地基基础工程专业承包一级,电子与智能化工程专业承包一级,建筑装修装饰工程专业承包一级,建筑幕墙工程专业承包一级",
for (EntQualificationVO vo : entQualificationVOList) {
String certNameList = vo.getCertNames();
List result = Arrays.asList(certNameList.split(","));
vo.setCertNameList(result);
}
结果: "certNameList": [
"消防设施工程专业承包二级",
"地基基础工程专业承包一级",
"电子与智能化工程专业承包一级",
"建筑装修装饰工程专业承包一级",
"建筑幕墙工程专业承包一级"
]
public static void main(String[] args) {
// 1、字符串转为List<String>
List<String> resultList = Arrays.asList("1", "2", "3");
System.out.println("方法一");
resultList.forEach(e -> {
System.out.print(e + " ");
});
System.out.println("");
System.out.println("方法二");
String msg = "4,5,6";
// 2、字符串转为List<String>
List<String> msgList = Arrays.asList(msg.split(","));
msgList.forEach(e -> {
System.out.print(e + " ");
});
System.out.println("");
// 3、List<String>转String
List<String> msgList2 = new ArrayList<>();
msgList2.add("a");
msgList2.add("b");
msgList2.add("c");
String msg2 = String.join(",", msgList2);
System.out.println("msg2=" + msg2);
String certNameList = "消防设施工程专业承包二级,地基基础工程专业承包一级,电子与智能化工程专业承包一级,建筑装修装饰工程专业承包一级,建筑幕墙工程专业承包一级";
List result = null;
for (int i = 0; i < certNameList.length(); i++) {
result = Arrays.asList(certNameList.split(","));
}
System.out.println(result);
}
标签:toList,专业,List,System,转化,字符串,承包,certNameList,out
From: https://www.cnblogs.com/codeLearn/p/17981600