Example: Evaluating a Condition in the Integrated Debugger

To see how to evaluate an expression in an if-statement condition without the program actually starting the statement, do the following steps:

  1. If the Hanoi Sample package has not yet been added from the repository to the workspace, add the package com.ibm.ivj.examples.hanoi from the IBM Java Examples project.
  2. Go to the method com.ibm.ivj.examples.hanoi.Hanoi.solve(int,Post,Post,Post).
  3. Set a breakpoint by double-clicking on the margin next to the following line:
    if (depth == 1)
  4. Run the Hanoi application.
  5. When the Debugger browser opens, select the solve(int,Post,Post,Post) method in the All Programs/Threads pane.
  6. In the Source pane, select the text depth == 1.  Click the Inspect button inspect.gif (1041 bytes).  An Inspector window will open, and the Value pane will display "false" (assuming the number of disks you started with was greater than 1).
  7. In the Source pane, select the next if condition, depth > 1.    Select Display from the selected text's pop-up menu.   The text "(boolean) true" will be inserted in the Source pane.  Press Delete to remove the inserted message.

Click the Terminate button terminate.gif (1022 bytes) to terminate the program.