my dog learned polymorphism
The moose likes Java in General and the fly likes Inner Class Final vaiable reference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Inner Class Final vaiable reference" Watch "Inner Class Final vaiable reference" New topic

Inner Class Final vaiable reference

Raveendran Hs

Joined: Feb 05, 2010
Posts: 23

for the above code i am getting below saying

Cannot refer to a non-final variable x inside an inner class defined in a different method

Q: why inner class method is not able to refer non final variable
Stephan van Hulst

Joined: Sep 20, 2010
Posts: 4635

Take a look here:

The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
I agree. Here's the link:
subject: Inner Class Final vaiable reference
It's not a secret anymore!