统计字符串中汉字的个数,字符串中字符自然排序

 1 public class Test11 {
 2     public static void main(String[] args) throws Exception {
 3         //统计汉字个数
 4         String ss = "1432去fad阿萨德撒sgi";
 5         byte[] b = ss.getBytes("GBK");
 6         if(b.length>ss.length()) {
 7             System.out.println("有汉字,个数为"+(b.length-ss.length()));
 8         }
 9         
10         System.out.println("===================================");
11         //字符串中字符排序
12         char[] cc = ss.toCharArray();
13         System.out.println("排序前字符串:"+ss);
14         Arrays.sort(cc);
15         ss = new String(cc);
16         System.out.println("排序后字符串:"+ss);
17     }
18 
19 }

 

posted @ 2018-11-17 21:58  束发读诗书  阅读(524)  评论(0编辑  收藏  举报