Step 7. Stepping Out of (returning from) a Method Call

previous step next step


Now that you have fixed the bug in the addFish method, we can remove the breakpoint for this method and also continue executing the program. Uncheck or remove the second breakpoint from the Breakpoints pane.

Press the Step Return button to direct the debugger to finish executing the current method. Execution halts just after the line that contained the call to the method that was being executed. The program should be stopped at the call to the addPiranha() method in the Aquarium class.

Step Into the addPiranha() method.

Step through a few lines of code, using either Step Into or Step Over . Before you get to the end of the addPiranha() method, press the Step Return button.

After stepping out of (returning) from the method, you should be back in the main() method. The next piece of code to be executed is the line of code following addFoodCenters(foodQty) line.

Continue exploring behavior of the Step Over , Step Into , and Step Return buttons.


previous step next step