CS 101 Lecture 19 - Debugging, Recursion Practice

Two Debugging Techniques

  1. Use the BlueJ debugger.

  2. Use "System.out.println" to display the values of key variables (not too many!) as the program executes.

    Example:

        if (DEBUG) {
            System.out.println("Base is " + base + " and n is " + n + ".");
        }
    
    where DEBUG is a constant set to true or false depending on whether you wish to see the debugging output or not.

Class Example:

  1. Let's allow damage to the broccoli structure.

    Click on BroccoliDamage to show the example.