public static int countLetter(String[] x, String y){
int count = 0;
for(int i = 0; i < x.length; i++){
for(int h = 0; h < x[i].length(); h++){
String yo = new String(x[i].substring(h,h+1));
if(yo==y){
count++;}
}
}
return count;
}
}
我的方法应该返回一个整数,该整数计算字母在数组的所有字符串中出现的总次数。(假设字符串是一个字母,我不能使用 charAt())。
慕斯709654
森林海
相关分类