Java 将List<String> 转为以逗号 ‘,’ 拼接的字符串

阅读 85

2022-08-02


代码: 

public static void main(String[] args) {
List<String> mobileList=new ArrayList<>();
mobileList.add("110");
mobileList.add("120");
mobileList.add("119");
String mobileStr= StringUtils.strip(mobileList.toString(),"[]").replace(" ", "");
System.out.println(mobileStr);
}

结果:

Java 将List<String> 转为以逗号 ‘,’ 拼接的字符串_逗号

依赖:

<!-- commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>

 

精彩评论(0)

0 0 举报