public class A
{
private static final int x;
public A()
{
x = 5;
}
}
final means the variable can
static final variables are initialized when the class is loaded. The constructor may be called much later, or not at all. Also, the constructor will be called multiple times (with each new object ), so the field could no longer be final.
If you need custom logic to initialize your static final field, put that in a static block