The first set of enclosing braces delineates the construction of an anonymous inner class, and the second set delineates the instance initializer for the anonymous inner class.
第一组闭合括弧划定一个匿名内部类的构造,第二组划定匿名内部类的实例初始化语句块。
Here, the ActionListener implementation is defined in place, as an anonymous inner class, and directly attached to the button.
这里,ActionListener实现是适时定义的,它定义为一个匿名内部类,并直接附加到按钮上。
This is an improvement over having to write a class any time an anonymous inner class is needed and can help keep the code more self-documenting.
相比于每个匿名内部类都要对应一个类的做法来说,这种方式是个极大的改进,同时也使得代码的可读性更好。
In fact, an anonymous inner class can't even extend a class and implement an interface at the same time.
事实上,一个匿名内部类甚至不能同时扩展一个类和实现一个借口。
In fact, an anonymous inner class can't even extend a class and implement an interface at the same time.
事实上,一个匿名内部类甚至不能同时扩展一个类和实现一个借口。
应用推荐