xhtml
 

Print Statements

One thing you can do to debug programs is to insert print statements at various places, to find out how far the program has got and what the values of the variables are at that point, like this:

System.out.println("Point A, n=" + n);

If you want to leave print statements in your program while you develop it further, you may want to add a global boolean variable debug and change this to:

if (debug) System.out.println("Point A, n=" + n);

Back