public class A
{
private static final int x;
public A()
{
x = 5;
}
}
final
means the variable can only be assigned once (in the constructor).static
means it's a class instance.
I can't see why this is prohibited. Where do those keywords interfere with each other?
Think about it. You could do this with your code:
The correct ways to initialise x are:
or