2.1 One level of indentation is four spaces.
2.2 All statements within a block are indented
one level.
2.3 Braces for classes and methods are alone
on one line.
The braces for class and method blocks are
on separate lines and are at the same indentation level,
for example:
public int getAge()
{
statements
}
2.4 For all other blocks, braces open at the
end of a line.
All other blocks open with braces at the end
of the line that contains the keyword defining the block.
The closing brace is on a separate line, aligned under the
keyword that defines the block. For example:
while(condition) {
statements
}
if(condition) {
statements
}
else {
statements
}
2.5 Always use braces in control structures.
Braces are used in if-statements and loops
even if the body is only a single statement.
2.6 Use a space before the opening brace of
a control structure's block.
2.7 Use a space around operators.
2.8 Use a blank line between methods (and constructors).
Use blank lines to separate logical blocks of code. This
means at least between methods, but also between logical
parts within a method.
|