import java.util.*;
public class MapTest
{
public static void main(String args[]){
String str = "fdg+avAdc bs5dDa9c-dfs";
getCharacterCount(str);
showCharacterCount();
}
private static TreeMap<Character,Integer> treeMap = new TreeMap<Character,Integer>();
public static void getCharacterCount(String str){
for(int i=0;i<str.length();i++){
if((str.charAt(i)>'a'&&str.charAt(i)<'z')||(str.charAt(i)>'A'&&str.charAt(i)<'Z') ){
Integer count = treeMap.get(str.charAt(i));
if(count==null){
treeMap.put(str.charAt(i),1);
}else{
count++;
treeMap.put(str.charAt(i),count);
}
}
}
}
public static void showCharacterCount(){
StringBuilder sb = new StringBuilder();
Set<Map.Entry<Character,Integer>> entrySet = treeMap.entrySet();
Iterator<Map.Entry<Character,Integer>> it = entrySet.iterator();
while(it.hasNext()){
Map.Entry<Character,Integer> entry = it.next();
sb.append(entry.getKey()+"("+entry.getValue()+")");
}
System.out.println(sb.toString());
}
}
public class MapTest
{
public static void main(String args[]){
String str = "fdg+avAdc bs5dDa9c-dfs";
getCharacterCount(str);
showCharacterCount();
}
private static TreeMap<Character,Integer> treeMap = new TreeMap<Character,Integer>();
public static void getCharacterCount(String str){
for(int i=0;i<str.length();i++){
if((str.charAt(i)>'a'&&str.charAt(i)<'z')||(str.charAt(i)>'A'&&str.charAt(i)<'Z') ){
Integer count = treeMap.get(str.charAt(i));
if(count==null){
treeMap.put(str.charAt(i),1);
}else{
count++;
treeMap.put(str.charAt(i),count);
}
}
}
}
public static void showCharacterCount(){
StringBuilder sb = new StringBuilder();
Set<Map.Entry<Character,Integer>> entrySet = treeMap.entrySet();
Iterator<Map.Entry<Character,Integer>> it = entrySet.iterator();
while(it.hasNext()){
Map.Entry<Character,Integer> entry = it.next();
sb.append(entry.getKey()+"("+entry.getValue()+")");
}
System.out.println(sb.toString());
}
}