package cn.itcast2;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;
public class Test14 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
// /
Scanner sc=new Scanner(System.in);
String string=sc.nextLine();
TreeMap<Character,Integer> tm=new TreeMap<Character,Integer>();
char[] arr=string.toCharArray();
for(char key:arr){
Integer value=tm.get(key);
if(value==null){
tm.put(key, 1);
}
if(value!=null){
tm.put(key, value+1);
}
}
Set<Character> keyset=tm.keySet();
for(Character keys:keyset){
int values=tm.get(keys);
System.out.println(keys+"("+values+") ");
}
}
} |
|