Java 将List<String> 转为以逗号 ‘,’ 拼接的字符串
代码:
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);
}
结果:
依赖:
<!-- commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>