我试图获取字符串数组中每个元素的平均长度。但不确定我的代码。有什么建议么?
public static double averageLength(String[] words, int count) {
double countedLength = 0.0;
for(int i = 0; i < words.length; i++) {
countedLength += words[i].length();
count++;
}
return (double)countedLength / count;
}
慕沐林林
桃花长相依
精慕HU
相关分类