
//str是个只包含小写字母的字符串,以下是统计每个字符出现的频数
int[] cnt = new int[26];
//toCharArray()
for (char ch : str.toCharArray()) {
cnt[ch - 'a']++;
}
//charAt()
for(int i = 0;i欢迎分享,转载请注明来源:内存溢出

//str是个只包含小写字母的字符串,以下是统计每个字符出现的频数
int[] cnt = new int[26];
//toCharArray()
for (char ch : str.toCharArray()) {
cnt[ch - 'a']++;
}
//charAt()
for(int i = 0;i欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)