简体   繁体   中英

Eclipse Java code style formatter

How to configure the Eclipse Java code style formatter to start the code following a brace on the same line as the brace?

class Example
{   Example()
    {
    }
    void bar(int p)
    {   for (int i = 0; i < 10; i++)
        {    //a comment
        }
    }
}

EDIT: Please read the question carefully. I am not asking a general question on how to use the formatter. It is easy to get the formatter to do this:

class Example
{
    //Code starts on the line following the brace
    Example()
    {
    }
}

It is NOT easy to get it to do this:

class Example
{   Example() //Code starts on the same line as the brace
    {
    }
}

Right click your project and go to properties. Then select Java Code Style > Formatter. Click New to create new formatter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM