From the workbench menu bar, select Window > Preferences. The Workbench Preferences page opens.
In the left pane, expand the Java category and select Code Formatter. The Code Formatter Preferences page opens.
In the New Lines, Line Splitting, and Style tabs, select the code formatting conventions that you want the formatter to follow.
Note that at the bottom of the page, you can observe an example effect of each individual code formatting option and see a preview of what your formatted code will look like.
Click OK when you are done.
Formatting Java code
Formatting files or portions of code