List转string 字符串,用逗号分隔。仅用于List是基本数字类型+String

1、将list转化为逗号分割的字符串

String str = String.join(",", list);

String str = StringUtils.json(list.toArray(), ",");  

2、将逗号分隔的字符串转换为List

List<String> list = Arrays.asList(str.split(","));

List<String> list = Arrays.asList(StringUtils.split(str, ","));


转载:https://blog.csdn.net/qq_27327261/article/details/134580779

posted @ 2024-08-20 17:05  了悟  阅读(953)  评论(0编辑  收藏  举报