总结:String是一个类。对于字串大小比较用方法:compareTo()
package com.da.ima2; public class gh { public static void main(String[] args) { // 定义一个Strging型数组。进行排序 String a[] = { "frgs", "aew", "ioju", "ted", "gwe" }; String temp; for (int i = 0; i < a.length - 1; i++) { for (int j = 0; j < a.length - i - 1; j++) { if (a[j].compareTo(a[j + 1]) > 0) { temp = a[j]; a[j] = a[j + 1]; a[j + 1] = temp; } } } for (int i = 0; i < a.length; i++) { System.out.println(a[i]); } } }