返回重复字符频率的方法
答案总是文本中所有字符的数量,而不是重复的字符!我可以知道如何编辑吗?
public static int freq(String in ) {
int frequency = 0;
char[] alphabet = "abcdefghijklmnopqrstuvwxyz".toCharArray();
for (int j = 0; j < 25; j++) {
for (int i = 0; i < in .length(); i++) {
if (alphabet[j] == in .charAt(i)) {
++frequency;
}
}
}
return frequency;
}