0
votes

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
    {
    }
}
1
Honestly this is one of those things you can Google and get over 500 different solutions. Like HERE for example. - Tdorno
Did you read the question? Specifically "start the code following a brace on the same line as the brace" - monzie
Is it me or are the two examples completely identical? - biziclop
Its just you. Example() is on a new line in the first instance, and on the same line as the opening brace in the second instance. - monzie
Would the downvoter care to explain his downvote or did he misinterpret the question because it wasn't read carefully? - monzie

1 Answers

0
votes

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