I have the following code:
public static void main(String[] args) {
final AbcClass worker = new AbcClass() {
@Override
public void sayHello() {
System.out.println("hello ");
}
};
JButton jButton = new JButton();
jButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
worker.sayHello();
}
});
}
Why the java compiler oblige me to put the worker object as a final?