//字符串 字符出现个数统计
private static String charAccounts(String orginStr){
char[] unDuplicateCharArray;
int[] charAccounts;
unDuplicateCharArray = removeDuplicateChar(orginStr).toCharArray();
charAccounts = new int[unDuplicateCharArray.length];
for(int i = 0; i < unDuplicateCharArray.length; i++){
for(char c : orginStr.toCharArray()){
if(unDuplicateCharArray[i] == c){
charAccounts[i] += 1;
}
}
}
//已字符串形式输出
String reStr = "";
for(int i = 0; i< unDuplicateCharArray.length; i++){
String s = unDuplicateCharArray[i]+ ":" + charAccounts[i]+" ";
reStr += s;
}
return reStr;
}
removeDuplicateChar
参考链接: 合并字符串中重复出现的字符(java实现)