Well, it ain't necessarily so. In addition to some conspicuous compile-time errors, your code can have other, less obvious errors.
Imagine someone telling you to “go to the intersection, and then rurn tight.” You notice immediately that the speaker made a mistake, and you respond with a polite “Huh?” The nonsensical rurn tight phrase is like a compile-time error. Your “Huh?” is like the jagged underlines in Eclipse's editor. As a listening human being, you may be able to guess what rurn tight means, but Eclipse's editor never dares to fix your code's mistakes.
In addition to compile-time errors, some other kinds of gremlins can hide inside a Java program:
This is an example of an unchecked runtime exception — the equivalent of someone telling you to turn right at the intersection when the only thing to the right is a big brick wall. Eclipse's editor doesn't warn you about an unchecked runtime exception because, until you run the program, the computer can't predict that the exception will occur.
Logic errors are the most challenging errors to find and to fix. And worst of all, logic errors often go unnoticed. In March 1985, a homeowner got a monthly home heating bill for $1,328,932.21. Clearly, some computer had printed the incorrect amount. When he called the gas company to complain about it, the telephone service representative said, “Don't be upset. Pay only half that amount.”
Imagine being told to “turn when you reach the intersection.” The direction may be just fine. But if you're suspicious, you ask, “Which way should I turn? Left or right?”
When you're sure that you know what you're doing, you can ignore warnings and worry about them at some later time. But a warning can be an indicator that something more serious is wrong with your code. Sweeping recommendation: Pay attention to warnings. But, if you can't figure out why you're getting a particular warning, don't let the warning prevent you from moving forward.
Dr. Barry Burd holds an M.S. in Computer Science from Rutgers University and a Ph.D. in Mathematics from the University of Illinois. Barry is also the author of Beginning Programming with Java For Dummies, Java for Android For Dummies, and Flutter For Dummies.