//字符统计
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import java.util.Map.Entry;
public class Sp
{
/**
* @param args
*/
public static void main(String[] args)
{
String str = "好啊abc hello";
Map<String , Integer> map = new HashMap<String , Integer>();
for(int i = 0 ; i<str.length() ; i++)
{
char ch = str.charAt(i);
if (isLetter(ch))
{
String temp = ""+ch;
int count = 0;
if (map.containsKey(temp))
{
count = map.get(temp);
}
map.put(temp , ++count);
}
}
System.out.println(toString(map));
}
public static boolean isLetter(char ch)
{
if ((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
{
return true;
}
else
{
return false;
}
}
public static String toString(Map<String , Integer> map)
{
String result = "";
Set set = map.entrySet();
Iterator it = set.iterator();
while (it.hasNext())
{
Entry me = (Entry) it.next();
result += me.getKey()+"("+me.getValue()+")";
}
return result;
}
}