Java String 和 String[] 相互转换
一、String 转 String[ ]//1.使用split()String[] strs = str.split(",");//2.创建一个String[] 数组,再给这个数组赋值private String[] strArray(String customerId){String[] customerIds = new String[1];customerIds[0] = customerI
![](https://csdnimg.cn/release/devpress/public/img/ic-book.4f347164.png)
一键AI生成摘要,助你高效阅读
问答
·
一、String 转 String[ ]
//1.使用split()
String[] strs = str.split(",");
//2.创建一个String[] 数组,再给这个数组赋值
private String[] strArray(String customerId){
String[] customerIds = new String[1];
customerIds[0] = customerId;
return customerIds;
}
//3. 创建一个List数组,再使用toArray()进行转换
String[] ids = strList.toArray(new String[strList.size()]);
二、String[] 转 String
public String doJoin(String[] strings) {
String result=String.join(",", strings);
return result;
}
更多推荐
所有评论(0)