public class sort {
public static void main(String args[]) {
String[] strs = {"come","go","bye","qq","javaeye"};
for (int i = 0; i < strs.length-1; i++) {
for (int j =i+1; j < strs.length; j++) {
int intTemp = strs[i].compareToIgnoreCase(strs[j]);
String strTemp = "";
if(intTemp>0){
strTemp = strs[j];
strs[j] = strs[i];
strs[i] = strTemp;
}
}
}
for (int i = 0; i < strs.length; i++) {
System.out.println(strs[i]);
}
}
}
按英文和中文首字母排序
最新推荐文章于 2020-11-10 15:10:06 发布