package test;
public class StringSplitTest {
/**
* @param args
*/
private String phone;
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String[] getDestinations() {
return this.phone.split(","); }
public static void main(String[] args) {
// TODO Auto-generated method stub
StringSplitTest msg = new StringSplitTest();
String str ="";
msg.setPhone("13439891234,13911041234"); //String[] str="13439897041,13911040389".split(",");
for(int i=0;i<msg.getDestinations().length;i++){
str+=msg.getDestinations()[i]+",";
}
System.out.println(str);
}
}
split的使用,
以及 String[]数组的遍历
本文展示了如何使用Java中的split方法对字符串进行分割,并遍历生成的字符串数组。
2258

被折叠的 条评论
为什么被折叠?



