|
 |
|
|
Adding new methods
-
Start adding a method by typing the following at the end of the VectorTest.java file (but before the closing
brace of the type) in the Java editor:
public void testSizeIsThree()
As soon as you type the method name in the editor area, the new method appears at the bottom of the Outline view.
In addition,
- error annotations (red boxes) appear in the overview ruler positioned on the right hand side of the editor,
- error icons appear in the vertical ruler positioned on the left of the editor,
- an error indicator appears in the top right corner of the editor,
- errors are marked in the text.
These error annotations indicate that the compilation unit is currently not correct. If you hover
over the error in the text, a tool tip appears: Syntax error on token ")",
{ expected after this token. This is correct since the method doesn't have a body yet. Note that error
annotations in the editor are updated as you type. This behavior can be controlled via the
Report problems as you type option located on the
Java > Editor
preference page.
-
Click the Save button. The compilation unit is compiled automatically and errors appear in the
Package Explorer view, in the Problems view and on the vertical ruler (left hand side of the editor). In the Package
Explorer view, the errors are propagated up to the project of the compilation unit containing the error.
-
Complete the new method by typing the following:
{
//TODO: Check size
Note that the closing curly brace has been inserted automatically.
-
Save the file. Notice that the error indicators disappear since the
missing brace has been added.
Java editor
Java Editor Preferences
|
|
|