next up previous
Next: Preserve your program for Up: Programming assignment Previous: Type in another program

Make mistakes

It is a good idea to commit as many errors as you can think of with this program, so that you see what error messages the compiler produces. Sometimes the compiler will tell you exactly what is wrong, and all you have to do is fix it. Sometimes, though, the compiler will produce wildly misleading messages. You will develop a sense for when you can trust the compiler and when you have to figure things out yourself.

1.
Do the exercise on page 23 of the textbook, numbers 1a through 1d.
2.
Remove line 6.

3.
Bring line 6 back, but spell temperature wrong.

4.
Instead of calling it temperature, call it class, or void, or int, or any of the other reserved keywords in table 2.1 on page 25.

5.
Delete one of the quotation marks that end a string. Add an extra one.

6.
Delete one of the parentheses in an expression. Add an extra one.

How many of the syntax rules of Java can you guess just by the error messages from the compiler? If you are ever unsure whether something is legal in Java or not, ask the compiler!


next up previous
Next: Preserve your program for Up: Programming assignment Previous: Type in another program
Allen B. Downey
2/7/1998