This Q rather for verification:
A static final field can be initialized when it's declared:
public static final int i=87;
or in the static block:
public static final int i;
//..........
static {
...
i=87;
...
}
Is there anywhere, other than the static block, a static final field
public static final int i;
can be initialized?
Thanks in advance.
Note: saw Initialize a static final field in the constructor. it's not specific that the static block is the only place to initialized it outside the declaration.
//==============
ADD:
extending @noone's fine answer, in response to @Saposhiente's below:
mixing in some non-static context:
public class FinalTest {
private static final int INT = new FinalTest().test();
private int test() {
return 5;
}
}