I am confused about the concept of interface when dealing with anonymous inner class. As far as I know that you can't instantiate an interface in Java, so the following statement would have a compile error
ActionListener action = new ActionListener(); // compile error
What happen when it deals with anonymous class? why does it allow to use new? For example:
JButton button = new JButton("A");
button.addActionListener(new ActionListener(){ //this is fine
@Override
public void actionPerformed(ActionEvent e){
}
};
Does the compiler just make a class and implement ActionListener behind the scene? How does it work?