62,614
社区成员
发帖
与我相关
我的任务
分享
import java.util.ArrayList;
import java.util.List;
public class Split4 {
public static void main(String args[]) {
String Str = "aa-bb-cc-dd";
int i = 0;
List<String> l = new ArrayList<String>();
try {
while (Str.indexOf("-") > -1) {
l.add(Str.substring(i, Str.indexOf("-",i)));
i = Str.indexOf("-",i) + 1;//
}
} catch (RuntimeException e) {
e.printStackTrace();
}
System.out.println(l);
}
}
import java.util.ArrayList;
import java.util.List;
public class Split4 {
public static void main(String args[]) {
String Str = "aa-bb-cc-dd";
int i = 0;
List<String> l = new ArrayList<String>();
try {
while (Str.indexOf("-", i) > -1) {
l.add(Str.substring(i, Str.indexOf("-",i)));
i = Str.indexOf("-",i) + 1;//
}
} catch (RuntimeException e) {
e.printStackTrace();
}
System.out.println(l);
}
}