12345
23456
89
23456789
即把一个串从数字不连续的位置断开作者: TS-松子 时间: 2016-5-30 16:30
public class Demo {
public static void main(String[] args) {
String s = "12345234568923456789";
char[] ch = s.toCharArray();
int a = 0;
for (int i = 1; i < s.length(); i++) {
int b = ch[i]-ch[i-1];
if (b==1) {
continue;
}
System.out.println(s.substring(a, i));
a = i;
}
System.out.println(s.substring(a,s.length()));
}
}