If I want to initialize a local variable in an ActionListener I get this error:
Local variable word defined in an enclosing scope must be final or effectively final.
The code looks something like this:
int number = 0;
anyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
//And here I get the error:
number++;
}
});
Do you know how to do it?