Acc to me(with ref to the above code) Final variables are not assigned default values ever but i hv not read this statement in any book i hv read abt java......
Can somebody please clarify this fact!!!....
A blank final is a final variable whose declaration lacks an initializer.
Once a final variable has been assigned, it always contains the same value
in your case the blank variable is an instance variable, so you can only access the variable after the constructor execution. so it make sense to initialize i value in constructor.
remember if the variable i is static, then you need a static initializer instead of constructor to initialize i value
the final instance variables area needed to be given value in the same line or in every constructor
this is because
before the constructor runs, the default values are assigned to the instance variables after the super class constructor has completed execution
so when we write
final int i ;
then the value i = 0 is automatically given to i
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right