I read 2 things
final
should be intialized during declarationblank final variable
which should be assigned at last line in constructorOtherwise, you will get CTE
.
My question is,
Why Java allows to assign/initialize value of final in constructor?
Because each instance can have it's own final
value for it. And that can be done only through constructor because you can call constructor only once. If you want to make sure that the block gets executed only once and that too while creating the instance, constructor is the only place.
If you hard code in the class (initialising while declaring), that will be same for all the instances and almost become static.