注册 登录
编程论坛 J2EE论坛

解释一下借口实例化的意思

弱智抓蛙男 发布于 2006-11-29 18:40, 633 次点击
程序片段如下:
ActionListener WthUpdateHandler =
new ActionListener() {
public void actionPerformed(ActionEvent e) {
// code to process add new customer request
// fire event -- inform registered controllers
InfoController con;
for (int i=0; i<listeners.size(); i++){
System.out.println("View " + viewId +
": fire wthUpdate event");
con = (InfoController) listeners.get(i);
con.processWthUpdate(wthText.getText());
}
}
};

不明白把一个接口实例化了 是个什么意思
我只是知道把类实例化,不明白把接口实例化的用意
哪位大侠不吝赐教。
2 回复
#2
神vLinux飘飘2006-11-29 21:37
接口,实例化??你强~~..接口不能实例化
#3
千里冰封2006-11-29 21:41

你这不是接口实例化,而是创建了一个匿名内部类,它实现了这个接口,所以可以把它的引用赋给这个接口

1