It is permissible to remove braces in case they are superfluous. This not only applies to the control statements if, for, while and do-while, but also to every block in general (remember a block is just a sequence of statements, local class declarations and local variable declaration statements within braces).
Note that the insert and remove braces options are mutually exclusive.
When enabled, braces around the body of if...else statements are removed when possible.
Example 2.57. Brace removal for if statements
if (true) { break; } else { return; }
would become
if (true) break; else return;
When enabled, braces around the body of for statements are removed when possible.
Example 2.58. Brace removal of for statements
for (int i = 0; i < count; i++) { System.out.println(i); }
would become
for (int i = 0; i < count; i++) System.out.println(i);
When enabled, braces around the body of while statements are removed when possible.
Example 2.59. Brace removal for while statements
while (!isDone) {
doSomething();
}
would become
while (!isDone)
doSomething();
When enabled, braces around the body of do...while statements are removed when possible.
Example 2.60. Brace removal for do...while statements
do { something(); } while (condition);
would become
do something(); while (condition);
When enabled, braces are removed around the body of labeled statements inside switch blocks when possible.
Since 1.8
Example 2.61. Brace removal for switch
switch (c) { case 'a': case 'b': { System.out.println(); break; } }
would become
switch (c) { case 'a': case 'b': System.out.println(); break; }
When enabled, arbitrary block braces are removed when possible.