// suport AA->ZZ,A=65,Z=90
List<String> list = new ArrayList<String>(128);
String num="78";
String start = "AA";
String end = "EE";
list.add(start+num);
char start1 = start.charAt(0);
char start2 = start.charAt(1);
char end1 = end.charAt(0);
char end2 = end.charAt(1);
while (end1 >= start1 || end2 > start2) {
if ((++start2) == ('Z' + 1)) {
start1++;
start2 = 'A';
}
list.add(start1+""+start2+num);
// System.out.println(start1+""+start2);
}
list.add(end+num);
//String exp=StringUtils.join(',');
StringBuffer exp= new StringBuffer();
for(String c:list){
exp.append(",").append(c);
}
在网上没有找到更好的方法,如有想法,欢迎指正。

本文介绍了一种使用Java实现的字符序列生成算法,该算法能够生成从指定起始字符到结束字符之间的所有组合,并附加特定数字。通过循环和条件判断完成字符的递增,最终将生成的字符串存入列表并输出。
1255

被折叠的 条评论
为什么被折叠?



