Adding new methods

  1. Start adding a method by typing the following at the end of the 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.

    New method in outline view

    In addition, 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 Goto the Java editor preference page Java > Editor preference page.

    Error annotations in vertical and overview ruler

  2. 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.

    Error propagation in package explorer

  3. Complete the new method by typing the following:

      //TODO: Check size

    Note that the closing curly brace has been inserted automatically.
  4. Save the file. Notice that the error indicators disappear since the missing brace has been added.
Java editor
Java Editor Preferences