ArrayList AP CSA remove loop practice

AP CSA ArrayList Remove Loop Practice

ArrayList removal questions test whether students understand that indexes change immediately. The code may compile and still skip values, remove the wrong item, or throw an index error.

Best For

When to use this page

Students who know ArrayList methods but lose points when a loop removes multiple matching elements.

Practice Prompts

Try these before moving on

1

Trace a forward loop that removes all short words from an ArrayList and explain which elements are skipped.

2

Rewrite the loop so it safely removes all matching items.

3

Compare removing into a new list versus mutating the original list in place.

Common Mistakes

What to check in your answer

Incrementing i after remove(i) when the next item shifted into the same index.
Using an enhanced for loop while changing the list.
Forgetting that remove returns the removed value and changes size.