Problems with Inner Classes
Hey, I'm trying to change a non-final variable when a button is clicked in my program. The problem I'm running into is that, as far as I know, you can't use non-final variables within an actionlistener which means I'm unable to alter the variable which I want to alter when the button is clicked.
I've looked over a few google pages but so-far I haven't found anything that would give me a way around this predicament. If anyone has a solution or even a suggestion as to how to solve this problem, thanks in advance!
Re: Problems with Inner Classes
The variable must be declared final if it is only within the scope of the method creating the inner class. If it is say a class field, and this class contains a method that creates the inner class than this should be fine. I'd recommend posting an SSCCE if you are still having trouble.
Re: Problems with Inner Classes
Can you post the code you are having problems with.
An inner class should be able to access class variables.
Re: Problems with Inner Classes
Edit: After a bit of messing around the problem has been solved thanks to both of your comments. Thanks!