简体   繁体   English

方法的返回值(Java)

[英]Return value from method (Java)

ok.addActionListener(new ActionListener ()
            {
                @Override
                public void actionPerformed(ActionEvent e) {
                   //need to return value from method
                }
});

I created button and now I need to return value that I have in actionPerformed .我创建了按钮,现在我需要返回actionPerformed值。 How to do it?怎么做?

It is not possible to return a value from actionPerformed().不可能从 actionPerformed() 返回值。 You can instead do something like: AClass.setReturnValue(whatever you wanted to return) and then do an action base on that.您可以改为执行以下操作: AClass.setReturnValue(whatever you wanted to return)然后在此基础上执行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM