public class A
{
private static final int x;
public A()
{
x = 5;
}
}
final means the variable can
Think about what happens the second time you instantiate an object. It tries to set it AGAIN, which is expressly prohibited by being a static final. It can only be set one time for the entire class, not instance.
You should set the value when you declare it
private static final x=5;
If you need additional logic, or more complex instantiation, this can be done in a static initializer block.