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] = 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;		
}