Java blank final, Java blank final
Blank final refers to the domain declared as final but not given an initial value.
The final must be assigned a value at the definition of the domain or each constructor using an expression to ensure that the final must be initialized before use.
Java blank final
Blank final values can be assigned without definition. The variables a and f defined in the main class are correct.
The problem lies in the constructor. In the two constructor, only one of them will be called during instantiation, resulting in a variable not initialized.
For example, when FinalTest x = new FinalTest (2);, a has a value, but f is not initialized.
In java, what is final used in parameters?
Final variable modification means that the reference of the variable is unchangeable. In your example, the reference of helloService cannot be re-assigned ..