Why must a final variable be initialized before constructor completes?

The official reason is that it is defined by the Java Language Specification 8.3.1.2:

A blank final instance variable must be definitely assigned at the end of every constructor of the class in which it is declared; otherwise a compile-time error occurs.

A blank final is a final variable whose declaration lacks an initializer (i.e. what you describe).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)