Anonymous ClassYou can declare an inner class without naming it. button.addActionListener(new ActionListener() {
int xyz; //instance variable(s)
....
public void actionPerformed(ActionEvent e) { //override method(s)
....
}
});Anonymous classes can make code difficult to read. You should limit their use to those classes that are very small (no more than a method or two) and whose use is well-understood (like the Swing event-handling adapter classes). |