The variable i , defined inside the baz method, is finally final, because the value of the variable i does not change elsewhere. If you change it
void baz(){ int i = 0; i = 2; class Bar{ int j = i; } }
The code will not compile because the variable i ceases to be finally final, but if you just declare the variable i and initialize it on a different line, the code will be compiled because the variable is finally final
void baz(){ int i; i = 2; class Bar{ int j = i; } }
source share