Use the Java editor features such as content assist and code formatting

Using content/code assist

You can use content assist (also called code assist) when writing Java code or Javadoc comments.

  1. Place your cursor in a valid position on a line of code in an editor and either:

    • Press Ctrl + Space

    • Select Edit > Content Assist from the menu bar

    If the Java editor finds valid candidates for this position, a list of possible completions is shown in a floating window. You can type further to narrow the list. You can also hover over the selected list items to view its Javadoc information, if it is available.

  2. Use the arrow keys or the mouse pointer to navigate through the possible completions.

  3. Select an item in the list to complete the fragment by doing one of the following:

    • Selecting it and pressing Enter

    • Double-clicking it

    • NOTE: When a list item is selected, you can view any available Javadoc information for this item in hover help. Note that you must click an item to select it in the list before you can view Javadoc hover help for it.

NOTE: If one of the trigger characters is typed inside Java source code (by default '.') (but not inside a Javadoc comment) and no other character is typed before the auto activation delay times out (by default 500 ms), the code assist is invoked.

Content/Code Assist

Formatting files or portions of code

To format Java code:

  1. Use the Code Formatting Preferences page (Window > Preferences > Java > Code Style > Code Formatter) to specify your preferences for code formatting.

  2. Open a Java file and select the code you want to format. If nothing is selected, then all of the editor content is formatted.

  3. Format the code by either:

    • Selecting Source > Format from the editor's pop-up menu or

    • Pressing Ctrl + Shift + F or

    • Selecting Source > Format from the menu bar.

Professional hosting     Belorussian informational portal         Free SCBCD 1.3 Study Guide     Free SCDJWS 1.4 Study Guide     SCDJWS 1.4 Quiz     Free IBM Certified Associate Developer Study Guide     Free SCJP 5.0 (Tiger) Study Guide     Free Mock Exam Engine     Free SCWCD 1.4 Study Guide     IBM Test 000-287. Enterprise Application Development with IBM WebSphere Studio, V5.0 Study Guide