The
command behaves similarly to except that if the next line of code to be executed calls a method, then descends into the method. This allows you to execute the method line-by-line in the debugger.If you've followed the tutorial exactly as directed in this tutorial, your program will be halted just before executing the line:
input = new inputBox(tank);
Since we know a bug that we're trying to fix, let's focus on that
bug first. We know that the number of fish created was incorrect,
so we will want to set a breakpoint and run the debugger until
we reach that point in the main method.
Scroll through the main method until you find the call
to the addFish()
method. Set a breakpoint
at this line. Your window should look similar to this.
Press the
button. This will run the debugger until it reaches the newly set breakpoint. You will need to move or minimize any windows that obscure the input dialog box.Enter 3 fish, 2 piranha and 5 food centers as you did before.
Next, press the addFish()
method.
You should see the following:
The debugger is now showing the code of the addFish()
method.
The first line of the addFish()
method is highlighted.
This indicates that the addFish()
method has not yet been executed.
If we had chosen
instead of , the method would have been executed in its entirety and we would not have been given the opportunity to fix the addFish() method. With , you descend into any method that is called and can then watch individual lines of the method execute.If you do not have access to the source code or you are positive that the bug is not being caused by a specific method, choose the
button. If you will need to trace code in great detail, you should choose the button.Note: You will not be able to code for which you do not have access to the source.
It is very useful to have both
and commands. You will find that you will you use both frequently.We must now trace the execution of this method until we discover why it is adding one too many fish to the simulation. Before we continue using
or to follow the execution of this method we want to make sure that the value of the quantity parameter is correct.Provide me with a screenshot of your environment now.
Continue with the tutorial to see how to do this.