Grade 11 Computer Science · The bridge to Java
Reading an error from the check
How to untangle forty errors stemming from one mistake.
Forty errors, one mistake
The screen fills with forty red messages, and the instinct is to start fixing from top to bottom. That is the longest route. And there is one case in which even the line the message points at is the wrong place to look.
The messages from the checking stage look at first like a wall. They are long, there are many of them, and they use words not yet familiar. It is worth investing one lesson in reading them, because that saves most of the first month’s frustration.
int total = "seven";
// Report.java:4: error: incompatible types:
// String cannot be converted to int
// int total = "seven";
// ^
// where: the location, the kind, and both typesThe rule that saves most of the time
When one gets forty errors, there is nearly always one mistake that dragged all of them along — a brace not closed, a missing semicolon, a wrong class name. The check keeps reading after the first mistake and gets more and more confused, so every error after the first is suspect of being noise. The rule is to fix only the first and run again. Very often the forty drop to three.
| Kind of message | What it usually is |
|---|---|
| Incompatible types | A value of the wrong kind |
| Symbol not found | A typo or an undeclared name |
| A brace or semicolon expected | Something was not closed earlier |
Example 1 — why the second error is noise
- The check failed at the first line.
- It kept reading in a confused state.
- And everything after is affected.
Example 2 — why “symbol not found” is common
- A name written with a different letter.
- Or a variable never declared.
- The message names it exactly.