Practice · 4 of 5
Trace removal while iterating (E3)
CHALLENGE
Difficulty: advanced+25 XP
Trace this loop **on paper**:
``java
ArrayList<String> list = new ArrayList<String>();
list.add("a"); list.add("b"); list.add("c");
list.add("d"); list.add("e");
for (int i = 0; i < list.size(); i++) {
if (i % 2 == 0) { list.remove(i); }
}
System.out.print(list);
`
Return the printed contents exactly (bracketed, comma-space separated, as ArrayList prints — e.g. [b, d]`).
Press Submit to check your solution.
Back to lesson: Practice: Trace drills: state tables and misdirection