Exercise 5: Evaluating Variables

In addition to watching variables in the Threads/Stack tab, you can evaluate a variable from the Variables tab. Using the Variable tab is the quickest way to evaluate a variable if you already know the name of the variable. In this exercise, you will evaluate a variable and resume execution of the Blink applet.
  1. Bring the Debugger to the front and click the Variables tab.
    Find the line

    Scope: Class Blink in the file Blink.java at line 54

    near the bottom of the tab. This line indicates the scope of the evaluation. A variable has a value when it is within the scope of the current location on the call stack. In this case, the scope is a stack frame for a method in the file Blink.java at line 54.

  2. Type speed in the Evaluate text field on the left.

  3. Click the Evaluate button.
    The variable speed and its value, 400, appear in the scrolling list. The value 400 also appears in the right text field.

  4. Type d in the Evaluate text field and click the Evaluate button.
    The value of d is:

    java.awt.Dimension

    The glyph indicates the variable has embedded objects.

  5. Click the glyph.
    The WorkShop expands d to show the value of its two components, width and height.

  6. Click the Clear List button under the right text field.
    The WorkShop removes all entries from the evaluate list.

  7. Click the Resume All control in the Source Editor tool bar.
    The Blink project resumes executing in the Applet Viewer.

Next lesson:

Exercise 6: Ending a Debugging Session