Вопрос

Currently my eclipse follows this code format:

public class TempClass {
    public static void main(String[] args) {
    }

}

So when I select all code and press  Ctrl  +   Shift    +  F , it formatts the code in above style.

Is there any way I can set my default code format to this:

public class TempClass 
{
    public static void main(String[] args) 
    {
    }
}
Это было полезно?

Решение

Follow this:

Window -> Preferences -> Java -> Code Style -> Formatter -> [Edit...] -> Braces

There you can configure it!

Другие советы

Right click on project->java -> code Style->Formatter->Configure Workspace Settings..(link on top right)>Select Active Profile->Edit->Braces(Tab)

Look for Brace Position:

You can change the brace position, for eg) constructor declaration to next line

You can create a new profile as well if you want(instead of using the Eclipse Built-in]

enter image description here

Change the sample code.

and Apply changes.

Version:Helios Service Release 2

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top