Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How can you use a method local variable in a method local inner class?

user-image
Question added by himanshu mittal
Date Posted: 2013/06/25
Zabeer Sultan
by Zabeer Sultan , Senior Technical Lead , Happiestminds

We can use a method local variable in method local inner class only when the method local variable is final.
Only final variables can be accessed inside method local inner classes because JVM maintains a copy of the method local variables when the inner class object is created, so the final variable restriction is in place.

More Questions Like This