我有一个字符串数组,其中包含许多单词,例如:[abh、tft、aae、be、rec]。 如何对数组中包含指定字符的单词进行排序。现在我只能计算整个数组中特定字符的总数,但我想从每个单词中单独计算。我想将这些值分配给一些 int 列表。例如 [2, 0 , 3, 2, 2)
double counterABCDE = 0;
for (String s: splited) {
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == 'a' || s.charAt(i) == 'b' || s.charAt(i)
== 'c' || s.charAt(i) == 'd' || s.charAt(i) == 'e') {
counterABCDE++;
}
}
}