See my code below Note: originalSize--; I put this in because when I remove an item I need to stop sooner than otherwise or else I will be out of bound. It works, but then I noticed others' are working without it. Why do I need it and other don't? int originalSize = list.size(); for (int i = 0; i < originalSize; i++) { if (list.get(i).contains("r") && !list.get(i).contains("l")) { //System.out.println("string contains r but not l: " + list.get(i)); list.remove(i); i--; originalSize--; }