public Map<String, Integer> getCount(String str){
Map<String, Integer> map = new HashMap<String, Integer>();
if(!str.isEmpty()){
for(int i=0;i<str.length();i++){
String key = str.charAt(i)+"";
if(map.containsKey(key)){
int init = map.get(key);
map.put(key, init+=1);
}else{
map.put(key, 1);
}
}
}
return map;
} |
|