Fixing Errors

If errors exist in your program when you compile it, a message is displayed that explains each error and the lines on which they occurred. The following output illustrates an attempt to compile a program that has an error and the error messages that are displayed as a result:

C:\J24Work>javac Saluton.java
Saluton.java:4: cannot resolve symbol.
symbol  : method print1n (java.lang.String)
location: class java.io.PrintStream
        System.out.print1n(greeting);
                  ^
1 error

C:\J24Work>

Error messages displayed by the javac tool include the following information:

  • The name of the Java program

  • The number of the line where the error was found

  • The type of error

  • The line where the error was found

As you learned during the past hour, errors in programs ...

Get SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH EDITION now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.