Why the inner class can use local variables of the method only if they are marked final? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why the inner class can use local variables of the method only if they are marked final?

7th Feb 2017, 4:29 AM
gaurav kulkarni
gaurav kulkarni - avatar
2 Answers
0
I am not sure where you got that from, but as far as I know, an inner class can access any variables of the outer class...not just those which have the final modifier.
8th Feb 2017, 6:46 PM
Joanne Ong
0
Final doesn't modify visibility. Declaring a variable final makes it immutable. Declaring a variable public, private or protected changes its visibility.
20th Feb 2017, 7:06 AM
Nick
Nick - avatar