我有以下代码:
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();
}
});
}
为什么java编译器要求我将worker对象作为final?