import java.util.*;
class MapTest
{
public static void main(String[] args)
{
String tmp = new String("sdfgzxcvasdfxcavdf");
Map<Character,Integer> map = new TreeMap<Character,Integer>(new Comparator<Character>(){
public int compare(Character c1,Character c2)
{
return c1.compareTo(c2);
}
});
for(Character c : tmp.toCharArray())
{
if(map.containsKey(c))
{
Integer v = map.get(c);
map.put(c,v+=1);
}
else
map.put(c,1);
}
for(Iterator<Map.Entry<Character,Integer>> it = map.entrySet().iterator();it.hasNext();)
{
Map.Entry<Character,Integer> entry = it.next();
System.out.print(entry.getKey()+"("+entry.getValue()+") ");
}
}
}
class MapTest
{
public static void main(String[] args)
{
String tmp = new String("sdfgzxcvasdfxcavdf");
Map<Character,Integer> map = new TreeMap<Character,Integer>(new Comparator<Character>(){
public int compare(Character c1,Character c2)
{
return c1.compareTo(c2);
}
});
for(Character c : tmp.toCharArray())
{
if(map.containsKey(c))
{
Integer v = map.get(c);
map.put(c,v+=1);
}
else
map.put(c,1);
}
for(Iterator<Map.Entry<Character,Integer>> it = map.entrySet().iterator();it.hasNext();)
{
Map.Entry<Character,Integer> entry = it.next();
System.out.print(entry.getKey()+"("+entry.getValue()+") ");
}
}
}