posted 18 years ago
Thanks ShivKumar for your reply. As per your suggestion I modified my code as at //0 final int a; and at //1 included a=5 which gives compile time error "Cannot assign a value to final variable". So i commented //1 and again it complains that "variable a might not have been intialized".
That means we must initialize the variable a before the MethodLocalClass definition.
Again at //0 i removed final modifier, then the compiler error is "local variable a is accessed from within inner class; needs to be declared final"
Conclusion: To access a local variable inside inner class, that variable should be declared final as well as it should be initialized outside the inner class.
Please correct me, if I am wrong.
raja