I'm having trouble extracting the names that contain more than 3 "O" or "o" in them from a string array. I have to print them after. Where did I go wrong and how can I fix it?
static String[] towns = {"England", "France",
"Romania", "Germany", "Canada", "Russia",
"Eoeoeooero"};
public static void main(String[] args) {
for (int i = 0; i < towns[i].length(); i++) {
for (int j = 0; j < towns[i].length(); j++) {
if (towns[i].charAt(j) == 'o' || towns[i].charAt(j) == 'O') {
e++;
}
}
if (e > 3) {
System.out.println(towns[i]);
}
}
}
}