I've been trying so far to write a method ,removeEvenLength that takes an ArrayList of Strings as a parameter and that removes all of the strings of even length from the list. But so far I've been getting a IndexOutOfBoundsException and I don't know why.
Any help would be appreciated
public static ArrayList<String> removeEvenLength(ArrayList<String> list) {
int size = list.size();
ArrayList<String> newLst = new ArrayList<String>();
for (int x = 0; x < size; x++) {
if (list.get(x).length() % 2 == 0) {
list.remove(x);
}
}
return list;
}