我是 Java 新手。我试图查找这个语法,但找不到它。你能指出这是什么吗?
class actions{
...
public ActionListener WHATISTHIS = new ActionListener () {
public void actionPerformed (ActionEvent event) {
String action = event.getActionCommand ();
show_error ("Key unimplemented: " + action + ": "
+ keys.valueOf (action).get_html ());
refresh (action);
}
};
...
什么是 ActionListener 类型的对象?和对象的新代码之后的东西 {..}?我很困惑。通常我会看到类似的东西:
[MODIFIER] [TYPE] obj = new [TYPE]();
但在上述情况下,它是:
[MODIFIER] [TYPE] obj = new [TYPE](){...};