if (
for (
while (
do {
try {
public class SomeClass {
if () {
for () {
while () {
catch () {
switch () {
} else {
} else if () {
} catch () {
} finally () {
for (int i = 0; i < 10; i++) {
a + b
a == b
for (Type blah : blahs) {
"String " + "concatenation"
public boolean aMethod() { return something; }
if (a == b || b == c)
switch () { case 1:
Mandatory comment for when a case falls through, and when not stacking
switch () { case 1: // Fallthrough case 2:
switch () { case 1: case 2: case 3: case 4: case 5: // Fallthrough case 6:
Empty line between cases after break, return, or fallthrough
switch () { case 1: break; case 2:
Prefer early returns over method indentation. Example:
if (!precondition) { // Possibly cleanup return; } // Continue with task
Java standard class and method naming, with exception to McMMO in a class name
thisIsAMethod()
ThisIsAClass
McMMOCustomClass
No space before opening parenthesis for methods, or constructors
public void thisIsAMethod() {
public ThisIsAClass() {
Spaces after comma in method calls and constructors, not before
something.methodCall(variable, otherVariable);
Accessing of variables with this. only when necessary to resolve scope
Class variables always defined at the top, before the constructor
No empty line between class declaration and beginning of variable declaration
Always a empty line at the end of a method or constructor definition
Constructors come before methods, and are typically ordered from the ones with the least arguments to the most
Methods should be ordered in this manner:
No one-line if statements, they should all have brackets