//希望打印结果:a(1)c(2).....
import java.util.*;
class MapTest5
{
public static void main(String[] args)
{
String str = "aaddcc!#@$1bb";
String s = geCount(str);
System.out.println(s);
}
public static String geCount(String str)
{
char [] ch = str.toCharArray();
TreeMap<Character,Integer> map = new TreeMap<Character,Integer>();
int count=0;
for (int x=0;x<ch.length;x++)
{
if (!(ch[x]>='a' && ch[x]<='z' || ch[x]>='A' && ch[x]<='Z'))
{
continue;
}
Integer value = map.get(ch[x]);
if (value==null)
{
map.put(ch[x],1);
}
else
{
count = value+1;
map.put(ch[x],count);
}
count = 0;
}
Set<Character> set = map.keySet();
Iterator<Character> it = set.iterator();
StringBuilder sb = new StringBuilder();
while (it.hasNext())
{
Character key = it.next();
Integer in = map.get(key);