TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
TIOBE - Java Coding Standard
Search

Rule:  Basic101Checked automatically with code checker

Synopsis:Use standard brace style.
Language:Java
Severity Level:4
Category:Basic


Description:

Braces do not go on their own line; they go on the same line as the code before them. So:

class MyClass {
    int func() {
        if (something) {
            // ...
        } else if (somethingElse) {
            // ...
        } else {
            // ...
        }
    }
}

We require braces around the statements for a conditional. Except, if the entire conditional (the condition and the body) fit on one line, you may (but are not obligated to) put it all on one line. That is, this is legal:

if (condition) {
    body(); 
}

and this is legal:

if (condition) body();

but this is still illegal:

if (condition)
    body();  // bad!



Literature References:
Google Android Guidelines