Next: C. Trapezium rule for
Up: B. Dealing with errors
Previous: Compile-time errors
Contents
- If an exception occurs when you try and run the program, again,
look at the details written to the screen -- the line number and the
type of exception thrown -- then examine this area of your source
code. You may have written code that tries to go beyond the end of
an array for example.
- If you suspect a particular block of code may be causing
problems try surrounding it with the longer form of comment
/*/ which effectively removes it from your program
without lots of unnecessary deleting. Then compile (and run) the
program again to see if the error/exception still occurs -- if it
doesn't then the problem lies within the code that was commented out.
This method can be tried with both compiler and runtime errors.
- So long as the program compiles okay, you can add
System.out.println(...); to your program at strategic points
to determine how far the program gets before the exception is thrown.
This allows you to narrow down on where the problem code must be.
Next: C. Trapezium rule for
Up: B. Dealing with errors
Previous: Compile-time errors
Contents
RHUL Dept. of Physics