Java Language Oracle Official Code Standard Indentation

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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.



Got any Java Language Question?