一個(gè)無(wú)名內(nèi)隱類的問(wèn)題(Java)
ActionListener a1 = new ActionListener()
{
??????public void actionPerformed(ActionEvent e){
????????????String name =
??????????????????((JButton)e.getSource()).getText();
????????????txt.setText(name);
??????}
};
?
這是一個(gè)Button的ActionListener,使用了無(wú)名內(nèi)隱類。我又一個(gè)問(wèn)題,為什么這樣new ActionListener()可以呢???ActionListener可是一個(gè)interface啊。。。。能直接調(diào)用interface的construct嗎????