private static void getNextIndex(char[] chars,int c_index){
char value = chars[c_index];
if(value == ‘9’){
chars[c_index] = ‘0’;
if(c_index >= 1){
getNextIndex(chars,c_index-1);
}
}else{
chars[c_index]++ ;
}
}
/**
* 字符串的数字键值递增+1
*/
public static String getNextStr(String string){
String returnStr = "";
if(string != null){
string.replaceAll("\\S", "");
char[] subStrs = string.toCharArray();
if(subStrs.length >1){
getNextIndex(subStrs,subStrs.length-1);
}
returnStr = String.valueOf(subStrs);
}
return returnStr;
}
调用getNextStr(‘0001’) 的数字会变成0002