|
http://www.jindent.com |
Previous: Switch-Case
|
Next: Method/Constructor
|
try-catch)try-catch statementstry-catch statements can be formatted different then methods.| Brace style for Class/interface/annotation declarations |

| Left brace { new line |
|
public class MyClass { ... |
|
public class MyClass { ... |
| Right brace } new line |
| Indent left brace { |
|
public·class·MyClass ····{ ····... |
|
public·class·MyClass { ... |
|
public·class·MyClass·{ ... |
|
public·class·MyClass{ ... |
| Indent right brace } |
|
public·class·MyClass ····{ ····... ····} |
|
public·class·MyClass { ····... } |
| Indent after right brace } |
| Cuddle braces of empty blocks {} |
|
public class MyClass {} |
|
public class MyClass { } |
| Indent cuddled braces {} |
|
public·class·MyClass{} |
|
public·class·MyClass·{} |
| Prohibit blank lines after left brace { |
|
public class MyClass { ¶ // comment with a preceding blank line protected int field; ¶ // another comment ... } |
|
public class MyClass { // comment with a preceding blank line protected int field; ¶ // another comment ... } |
|
See also: | Jindent - Settings - Formatter - Java / SQLJ - Comments - Blank Lines , Jindent - Settings - Formatter - Java / SQLJ - Blank Lines |
| If number of lines in body is at least ... then insert blank line after { |
|
public class MyClass implements MyInterface { public String getString() { callMethodA(); callMethodB(); return callMethodC(); } } ¶ interface MyInterface { public String getString(); } |
MyInterface looks fine,
but class MyClass seems to be formatted too close:
The class head public class MyClass implements MyInterface { and the first method declaration
public String getString() { are connected too close and could cause confusion.
|
public class MyClass implements MyInterface { ¶ public String getString() { callMethodA(); callMethodB(); return callMethodC(); } } ¶ interface MyInterface { public String getString(); } |
MyClass seems to be much clearer and
interface MyInterface is still formatted as before.|
public class MyClass implements MyInterface { ¶ public String getString() { callMethodA(); callMethodB(); return callMethodC(); } } ¶ interface MyInterface { ¶ public String getString(); } |
infinite.| If number of lines in body is at least ... then insert blank line before } |
|
public class MyClass implements MyInterface { ¶ public String getString() { callMethodA(); callMethodB(); return callMethodC(); ¶ } ¶ interface MyInterface { public String getString(); } |
| Do not insert blank line before single left brace |
|
See also: | Jindent - Settings - Formatter - Java / SQLJ - Braces Style - Presets |