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 types

The 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 messageWhat it usually is
Incompatible typesA value of the wrong kind
Symbol not foundA typo or an undeclared name
A brace or semicolon expectedSomething was not closed earlier

Example 1 — why the second error is noise

  1. The check failed at the first line.
  2. It kept reading in a confused state.
  3. And everything after is affected.

Example 2 — why “symbol not found” is common

  1. A name written with a different letter.
  2. Or a variable never declared.
  3. The message names it exactly.
What failed, what was received and what was expected — the same structure as the good message you learned.