Next: Indentation
Up: White Space Usage
Previous: Blank lines
A single blank space (not tab) should be used:
- Between a keyword and its opening parenthesis. This applies to the following keywords: catch,for, if, switch, synchronized, while. It does not apply to the keywords super and this.
- After any keyword that takes an argument. Example: return true;
- Between two adjacent keywords.
- Between a keyword or closing parenthesis, and an opening brace "{".
- Before and after binary operators3 except .(dot).
- After a comma in a list.
- After the semicolons in a for statement, e.g.: for (expr1; expr2; expr3) {
Blanks should not be used:
- Between or after a 'dot' operator.
- Between a unary operator and its operand.
- Between a cast and the expression being casted.
- After an opening parenthesis or before a closing parenthesis.
- After an opening square bracket [ or before a closing square bracket ]. Examples:
a += c[i + j] + (int)d + foo(bar(i + j), e);
a = (a + b) / (c * d);
if (((x + y) > (z + w)) || (a != (b + 3))) {
return foo.distance(x, y);
}
Do not use special characters like form-feeds or backspaces.
Dennis Seah
Mon Jul 17 11:43:42 2006