<aside> ℹ️ What follows are our recommendations for proper code writing etiquette. These guidelines are based on similar guidelines at other organizations.
Each file must end with a newline sequence.
Files may not contain horizontal tab characters. Use blanks only for indentation.
No line may contain trailing blanks.
Do NOT put whitespace:
DO put whitespace:
In general, break (insert newlines in) lines before an operator, as in
... + 20 * X
+ Y
Do not separate a method name from the "(" in a method call with blanks. However, you may separate them with a newline followed by blanks (for indentation) on long lines.
The basic indentation step is 4 spaces.
Indent code by the basic indentation step for each block level (blocks are generally enclosed in "{" and "}"), as in
if (x > 0) {
r = -x;
} else {
r = x;
}
Indent 'case' labels at the same level as their enclosing 'switch', as in
switch (op) {
case '+':
addOpnds(x, y);
break;
default:
ERROR();
}
Indent continued lines by the basic indentation step.
Use { } braces around the statements of all 'if', 'while', 'do', and 'for' statements.
Place a "}" brace on the same line as a following "else", "finally", or "catch", as in
if (x > 0) {
y = -x;
} else {
y = x;
}
Put the "{" that opens a block at the end of a line. Generally, it goes at the end of the "if", "for", "while", "switch", "do", method header, or class header that contains it. If line length forces it to the next line, do not indent it, and put it alone on the line.
@Override
annotation.