Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Java Development User Guide
Previous Page Home Next Page

Adding new methods

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

    New method in 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 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.

Related concepts

Java editor

Related reference

Java Editor Preferences


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire