“此”参考在构建过程中转义?

“此”参考在构建过程中转义?,第1张

“此”参考在构建过程中转义

是的,因为在匿名内部类中,您可以这样访问它:

final class FooButton extends JButton {    Foo() {        super("Foo");        addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) {     FooButton button = FooButton.this;     // ... do something with the button }        });    }}

ActionListener
原则上,匿名对象的代码可以在对象完全初始化
FooButton
之前被调用并使用
FooButton



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5428589.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-11
下一篇2022-12-11

发表评论

登录后才能评论

评论列表(0条)

    保存