一个无名内隐类的问题(Java)
时间:2019-11-26 11:12:01
手机看文章
扫描二维码
随时随地手机看文章
[导读]ActionListener a1 = new ActionListener() { public void actionPerformed(ActionEvent e){
ActionListener a1 = new ActionListener()
{
public void actionPerformed(ActionEvent e){
String name =
((JButton)e.getSource()).getText();
txt.setText(name);
}
};
这是一个Button的ActionListener,使用了无名内隐类。我又一个问题,为什么这样new ActionListener()可以呢???ActionListener可是一个interface啊。。。。能直接调用interface的construct吗????





