Hints for Debugging the Program
- Run program
TestLab6
. Test 6 will still fail. Use the debugger to find the
statement that causes an Exception to be thrown. If you press F6
too fast
you might miss the statement that threw the exception; if that happens simply restart the debugger.
- Once you know which statement caused the exception to be thrown, set a breakpoint there and
restart the debugger.
- Use
F5
to get inside the method that causes the exception (you might have to press
F5
several times); this method is in class Snake.java
.
- You will see a loop inside this method. Repeatedly press
F6
; how many times is the
loop repeated before an exception is thrown? How many data items are there in the array being
examined inside the loop? How many times should the loop be repeated? Is the terminating
condition for the loop correct? What should the terminating condition be?