java action listener: implements vs anonymous class
问题 I am trying to teach myself Java and had a question that I wasn't able to answer so far. In some of my reading online I have found two ways of using action listener that seem to do the same thing. But I am trying to figure out what is the advantage/disadvantage of one over the other. Is it better to use anonymous class like this: public MyClass() { ... myButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { //doSomething } }); ... } or is it best to