Java Language Indentation


Example

  • Indentation level is four spaces.
  • Only space characters may be used for indentation. No tabs.
  • Empty lines must not be indented. (This is implied by the no trailing white space rule.)
  • case lines should be indented with four spaces, and statements within the case should be indented with another four spaces.
switch (var) {
    case TWO:
        setChoice("two");
        break;
    case THREE:
        setChoice("three");
        break;
    default:
        throw new IllegalArgumentException();
}

Refer to Wrapping statements for guidelines on how to indent continuation lines.