给你一个在论坛看到的思路 
public static void main(String[] args) { 
                String str = "bbbsdes333992kssa"; 
                char[] buf = str.toCharArray(); 
                 int[] num = new int[123]; 
                for (int i = 0; i < buf.length; i++) { 
                        num[buf[i]]++; 
                } 
                for (int i = 0; i < num.length; i++) { 
                        if((i>=65 && i<=90) || (i>=97&& i<=122)){ 
                                if(num[i]>0){ 
                                        System.out.print((char)i+"("+num[i]+")"); 
                                } 
                        } 
                } 
        } |