Question

A programmer is trying to debug an issue where an `ArrayList` (or equivalent dynamic array) in their Java/Python code unexpectedly throws an  `IndexOutOfBoundsException` during an iteration. Which debugging technique would be most effective to pinpoint the exact cause? 

A Setting a breakpoint at the start of the program and running it.
B Using print statements to display the list size and current index inside the loop.
C Commenting out the entire loop to see if the error disappears.
D Changing the `ArrayList` to a `LinkedList` without further investigation.
Practice Next

Hey! Ask a query