public class Test {
private static final int A;
static {
A = 5;
}
}
This way of initializing static final variable A works okay .
public class Test {
private static final int A;
static {
Test.A = 5;
}
}
This way gives compile error "Cannot assign a value to final variable 'A'.
Why?