Correcting Syntax Errors
File Problems.java contains a simple
Java program that contains a number of syntax errors. Save the
program to your directory, study it and correct as many of the
errors as you can find. Then compile the program; if there
are still errors, correct them. Keep correcting errors until the program runs. Some things to remember:
- Java is case sensitive,
so, for example, the identifiers public, Public, and
PUBLIC are all considered different. For reserved words such as
public and void and previously defined identifiers such as
String and System, you have to get the case just right. You will
learn the conventions about case soon, but for now you can look at a sample program ShowInterest.java, to see what case should be used with the line containing the word "main".
- Fixing one error in the program will often "expose" a subsequent error to the compiler. Your errors messages may change as you correct errors.
- Eclipse does a good job of identifying which lines in a program contain syntax errors, but it is not perfect. Sometimes the syntax error will not be exactly where Eclipse thinks it is, but the error will probably be nearby--perhaps within a line or two.
When the program compiles cleanly, run it.
To hand in:
Submit to Canvas your modified version of Problems.java that compiles and runs correctly.