日期:2014-05-20  浏览次数:20697 次

求一段java将字符转换为ascll码后排序的代码
求一段java将字符转换为ascll码后冒泡排序的代码

------解决方案--------------------
public static void test(){
String test1 = "abdc";
char[] test2 = test1.toCharArray();
char testc = '\0';
for (int i = 0; i < test1.length(); i++ ) {
for (int j = i; j < test1.length() - 1; j++) {
if (test2[j] > test2[j + 1]) {
testc = test2[j];
test2[j] = test2[j + 1];
test2[j + 1] = testc;
}
}
}
System.out.println(test2);
return;
}