简单的中文字符串排序
public class Test4 { @SuppressWarnings({ "rawtypes", "unchecked" }) public static void main(String[] args) { int i=0; String[] strs={"张三","李四","王五"}; Comparator c=Collator.getInstance(Locale.CHINA); Arrays.sort(strs,c); for (String str : strs) { System.out.println((++i)+"、"+str); } } }
输出结果:
世上无难事,只怕有心人