Organizing import statements

In this section you will organize the import declarations in your source code.  Open junit.samples/VectorTest.java file in the Java editor if you do not already have it open.

  1. Delete the import declarations by selecting them in the Outline view and selecting Delete from the context menu. Confirm the resulting dialog with Yes. You will see numerous compile warnings in the vertical ruler since the types used in the method are no longer imported.

    Outline view context menu

  2. From the context menu in the editor, select Source > Organize Imports. The required import statements are added to the beginning of your code below the package declaration.

    Organize imports

    You can also choose Organize Imports from the context menu of the import declarations in the Outline view.
    Note: You can specify the order of the import declarations using the Goto the organize imports preference page Java > Code Style > Organize Imports preference page.
  3. Save the file.

Related concepts

Java editor

Related reference

Organize Imports Preferences