inner class and local variable | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

inner class and local variable

why inner classes in java can't access to non-final local variables?

3rd Aug 2021, 9:58 AM
Mehran
Mehran - avatar
1 Answer
+ 5
Inner class in java cannot acess local variables of the method in which the local inner class because local variables of the method is the local variables of the method are kept on the stack and lost as soon as the method ends
5th Aug 2021, 7:55 AM
Mr Rogue Knight
Mr Rogue Knight - avatar