next up previous
Next: Indentation Up: White Space Usage Previous: Blank lines

Blank spaces

A single blank space (not tab) should be used:
  1. 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.
  2. After any keyword that takes an argument. Example: return true;
  3. Between two adjacent keywords.
  4. Between a keyword or closing parenthesis, and an opening brace "{".
  5. Before and after binary operators3 except .(dot).
  6. After a comma in a list.
  7. After the semicolons in a for statement, e.g.: for (expr1; expr2; expr3) {
Blanks should not be used:
  1. Between or after a 'dot' operator.
  2. Between a unary operator and its operand.
  3. Between a cast and the expression being casted.
  4. After an opening parenthesis or before a closing parenthesis.
  5. 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