R
Roedy Green
I have been working with IntelliJ which keeps making suggestions to
improve you code. One thing it likes to do is add finals wherever it
can.
This presumably helps the compiler generate better code at it makes
clear to maintenance programmers what you can count on staying fixed.
There are two idioms you might not know that allow final:
private static final int x;
static {
x = complicated Expression involving other constants;
}
This is good when order of initialisation matters. If you put the
code inside a static init, the order can't be ruined by a
code-beautifier that alphabetises or otherwise reorders fields.
also
private final int x;
Constructor ( )
{
x = something;
}
improve you code. One thing it likes to do is add finals wherever it
can.
This presumably helps the compiler generate better code at it makes
clear to maintenance programmers what you can count on staying fixed.
There are two idioms you might not know that allow final:
private static final int x;
static {
x = complicated Expression involving other constants;
}
This is good when order of initialisation matters. If you put the
code inside a static init, the order can't be ruined by a
code-beautifier that alphabetises or otherwise reorders fields.
also
private final int x;
Constructor ( )
{
x = something;
}