总结:主要是方法不同了。是compareTo()方法比较字符串大小
package com.s.x; import java.util.Arrays; public class Jay { public static void main(String[] args) { // 对String 数组进行排序 String s[] = { "fda", "wad", "qsa", "ass", "gad" }; for (int i = 0; i < s.length; i++) { System.out.print("," + s[i]); } String temp = null; for (int i = 0; i < s.length; i++) { for (int j = i; j < s.length - 1; j++) { if (s[i].compareTo(s[j]) > 0) {// 这里注意字符串间比较大小的方法。compteto temp = s[i]; s[i] = s[j]; s[j] = temp; } } } System.out.println(); // System.out.println(Arrays.toString(s)); for (int i = 0; i < s.length; i++) { System.out.print(s[i]); } } }