public Count{
public static void main(String[] args) {
String str = "ADFGZXCVASDFXCVDF";
countLetters(str );
}
public static void countLetters(String str){
if (str == null || str.length == 0){
return;
} str = str.toLowerCase();
HashMap<Character, Integer> map = new HashMap<Character, Integer>();
for(int i = 0; i<str.length(); i++){
char c = str.charAt(i);
if (map.containsKey(c)) {
map.put(c, map.get(c)+1);
}
else{
map.put(c, 1);
}
}
Iterator<Character> itr = map.keySet().iterator();
while(itr.hasNext()){
char c = itr.next();
System.out.println(c + "("+map.get(c).intValue()+")");
}
}
}
}