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 does the java compiler oblige me to put the work object as final?
source
share