variable can be initialized at the time of declaration, in any of the instance initializers, or in all of the constructors.
I don't think it needs to be initialized in all constructors?
In the last constructor there is just a call to the other constructor but no initialization in it.
Code: Select all
public class TestClass{
final int value; //not initializing here
{
//not initializing value here either
}
TestClass(){
value = 10;
}
TestClass(int x){
value = x;
}
TestClass(int a, int b){
this();
}
}