其实这样分隔,要不要考虑2个字符串之间除了逗号之外的空白呢?
public class Test {
public static void main(String[] args) {
String str = "zifuchun1,zifuchuan2,zifuchuan3,zifuchuan4";
String[] ary = str.split(",");//调用API方法按照逗号分隔字符串
for(String item: ary){
System.out.println(item);
}
}
}
----------------
zifuchun1
zifuchuan2
zifuchuan3
zifuchuan4