Note: Please keep the programs that you create today, in case you have a question about your grades for the ICEs at the end of the quarter. When you're working with a partner, each person should save his-or-her own copy.
ICE 02.1: Finding and Fixing Errors
Writing programs involves finding and correcting a variety of errors.
As a programmer, you will need to get comfortable with this "debugging" process. Your text mentions three types of errors:
- compile time (syntax errors)
- run-time (program errors)
- intent errors (logical errors)
Let's take a closer look at the compile-time errors.
ICE 2.1.1: Create Your Own Compile-Time Errors
Open one of the programs you've previously used.
Make changes in the text and see which ones introduce errors – for example, add characters (letters, numbers, etc), delete characters, add white space (tabs, spaces, and the return key), change the case of characters, etc.
After each change, re-compile the code and see if an error occurs. Make a note of what Java considered errors and what it doesn't.
ICE 2.1.2: Correct Several Compile-Time errors
Download the FindErrors.java file, which is provided for you here or on the course website.
You should record each and every error that you find in your own copy of the Program Debug Table (which you should download here or from the course website).
Try to follow this debugging strategy (listed in your text) to find and correct the syntax errors in the file.
1. Compile the program to get a list of errors
2. Fix the most obvious errors, beginning with the first error reported
3. Compile the program again to get a revised list of the remaining errors
You should also save your own personal copy of the Program Debug Table, and record the errors that you find in that.
NOTE: It's always useful to view line numbers (because jGRASP tells us which line a syntax error is on).
You can get jGRASP to show line numbers using the View Line Numbers menu item. You will need to do this for each and every file you open.