These are our basic style rules for new Java code in LanguageTool. For IntelliJ IDEA, you might want to use these inspection settings.
if
block.final
for parameters or local variables, but write your
code as if there was a final
, i.e. do not re-assign local variables.
Configure your IDE to help you with that.
final
for member variables if possible.@deprecated
javadoc tag to document the method/class
to be used instead.@since x.y
javadoc annotation to all new non-private methods,
with x.y
being the version number of the next release.@Nullable
to methods that might return null
, no matter if
these methods are public or not.Examples for proper use of whitespace:
if (var == 2) {
statements;
}
if (var != 3) {
statements;
} else {
statements;
}
if (var == 1 && foo == 5) {
statements;
} else if (condition) {
statements;
} else if (condition) {
statements;
}
try {
statement;
} catch (Exception e) {
statement;
} finally {
statement;
}