本文实例讲述了Java编程实现汉字按字母顺序排序的方法。分享给大家供大家参考,具体如下:String[] str0 = new String[]{"abd","ervcd","sdfc","abdc","sded","生活","文教","政
本文实例讲述了Java编程实现汉字按字母顺序排序的方法。分享给大家供大家参考,具体如下:
String[] str0 = new String[]{"abd","ervcd","sdfc","abdc","sded","生活","文教","政治"};String[] str1 = new String[]{"生活","文教","政治","自然","宗教"};String[] str2 = new String[]{"张三","李四","王五","自然","戴阿","戴生"};String[] str3 = new String[]{"李四","张三","繁體字","無效","對繁","軍事","經貿"};//对简体字有效,对繁体字无效Comparator comp = Collator.getInstance(java.util.Locale.CHINESE);Arrays.sort(str0, comp);Arrays.sort(str1, comp);Arrays.sort(str2, comp);Arrays.sort(str3, comp);for(int i=0;i<str0.length;i++){ System.err.print(str0[i]+" ");}System.err.println();for(int i=0;i<str1.length;i++){ System.err.print(str1[i]+" ");}System.err.println();for(int i=0;i<str2.length;i++){ System.err.print(str2[i]+" ");}System.err.println();for(int i=0;i<str3.length;i++){ System.err.print(str3[i]+" ");}
--结束END--
本文标题: Java编程实现汉字按字母顺序排序的方法示例
本文链接: https://lsjlt.com/news/224976.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0