某字符串"adc,sff,ssffs,ss3dd,dfG88,sf23,33",不使用split方法按 " , " 拆分成字符串,并输出。
控制台输出:
adc
sff
ssffs
…
33
package entity;
public class SplitDemo {
public static String split(String str) {
if (str.indexOf(",") != -1) {
System.out.println(str.substring(0, str.indexOf(",")));
return split(str.substring(str.indexOf(",") + 1));
} else {
System.out.println(str);
return str;
}
}
public static void main(String[] args) {
String str = "adc,sff,ssffs,ss3dd,dfG88,sf23,33";
split(str);
}
}