Home Curly brackets and indentation

Always include curly brackets

Always include curly brackets, even for one-line if statements or for loops.

Indentation and nesting

When you see a matching set of opening and closing curly brackets, indent all lines of code in between by one additional level. Be consistent in how big each indent is.

Curly brackets and indent style

There are many different conventions on how exactly you should place your curly brackets. We strongly suggest you stick to standard Java conventions, but you are free to pick whatever convention you want as long as it isn't too bizarre, and more importantly, you follow it consistently.

Expand for details on our recommended style.