CS 46A - Lecture 18

Cover page image

Pre-class reading

The First Bug

The First Bug

Using a Debugger

The Debugger Stopping at a Breakpoint

Figure 5 - Stopping at a Breakpoint

Inspecting Variables

Figure 6 - Inspecting Variables

Debugging

Single-step Example

Lecture 18 Clicker Question 1

In the debugger, you are reaching a call to System.out.println(n). What should you do next?

  1. Step over it
  2. Step into it
  3. Inspect n
  4. Set a breakpoint

Lecture 18 Clicker Question 2

In the debugger, you are reaching the beginning of a long method with a couple of loops inside. You want to find out the return value that is computed at the end of the method. What should you do next?

  1. Step over the method
  2. Step into the method
  3. Inspect the method parameters
  4. Set a breakpoint