23:02:28
张开阳 2015/8/13 23:02:28
public class ChartoTree {
public static void main(String[] args) {
String s = "cbxzbvavdvgd";
char[] cha = s.toCharArray();
TreeMap<Character, Integer> tm = new TreeMap<Character, Integer>();
for (char c : cha) {
Integer it = tm.get(c);
if (it == null) {
tm.put(c, 1);
} else {
tm.put(c, it + 1);
}
}
Set<Character> keys = tm.keySet();
for (Character key : keys) {
Integer i = tm.get(key);
System.out.println(key +""+i);
}
}