一、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;		
}
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐