September 2019
Intermediate to advanced
816 pages
18h 47m
English
As a quick reminder, starting in Java SE 8, a local class can access local variables and parameters of the enclosing block that are final or effectively final. A variable or parameter whose value is never changed after it is initialized is effectively final.
The following snippet of code represents the use case of an effectively final variable (trying to reassign the ratio variable will result in an error, which means that this variable is effectively final) and two final variables (trying to reassign the limit and bmi variables will result in an error, which means that these variables are final):
public interface Weighter { float getMarginOfError();}float ratio = fetchRatio(); // this is effectively ...