A constructor in an interface?
I'm reading an article about inner class. I found an example that
demonstrates anonymous inner class (mentioned below).
button1 = new JButton();
button2 = new JButton();
...
button1.addActionListener(
new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
// do something
}
}
);
According to the example it creates an inner class for responding to a
button using ActionListener interface. As I know an interface does not
have a constructor. But I'm wondering, how they call a constructor.
"new java.awt.event.ActionListener(){ }"
No comments:
Post a Comment