What's the proper way to format "if" statements in Java with multiline "ands" or "ors"? [closed]

Apparently "if", "and", and "or" are such generic search parameters that I can't find the answer on google for my life. Which of these is the correct format according to the Java standards?

Option 1:

if (condition1
    && condition2
    && condition3) ...

or Option 2:

if (condition1 &&
    condition2 &&
    condition3) ...

The Oracle/Sun guidelines ("Code Conventions for the Java TM Programming Language") tell us to break before an operator. And they give this example.

if ((condition1 && condition2)
        || (condition3 && condition4)
        ||!(condition5 && condition6)) {
    doSomethingAboutIt();
} 

Many companies that I've worked for adopt the Oracle/Sun guidelines as the standard for their own code.

Refer http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-136091.html#248


I believe the correct answer is <CTRL>+<SHIFT>+F in Eclipse :)


This is completely subjective. Coding standards vary from shop to shop. To steal from yshavit's comment: Do whatever you want unless you are working in a team environment, in which case you should follow the team standards.

I'm a fan of the second pattern.