Fixing Errors

Now that the Spartacus application has been written, compiled, and run, it’s time to break something to get some experience with how NetBeans responds when things go terribly wrong.

Like any programmer, you’ll have plenty of practice screwing things up on your own, but pay attention here anyway.

Return to Spartacus.java in the source editor, and take the semicolon off the end of the line that calls System.out.println() (line 17 in Listing A.1). Even before you save the file, NetBeans spots the error and displays a red alert icon to the left of the line (see Figure A.5).

Figure A.5. Flagging errors in the source editor.

Image

Hover over the alert icon to see a dialog appear that describes the error NetBeans thinks it has spotted.

The NetBeans source editor can identify most of the common programming errors and typos that it encounters as you write a Java program. It stops the file from being compiled until the errors have been removed.

Put the semicolon back at the end of the line. The error icon disappears, and you can save and run the class again.

These basic features are all you need to create and compile the Java programs in this book.

NetBeans is capable of a lot more than the features described here, but you should focus on learning Java before diving too deeply into the IDE. Use NetBeans as if it were just a simple project manager and text editor. Write classes, flag errors, and make sure you can compile and run each project successfully.

When you’re ready to learn more about NetBeans, Oracle offers training and documentation resources at www.netbeans.org/kb.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.102.248