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()));
}
} |