Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个函数,它向服务器发送一条消息,如果答案到达,另一个函数将被调用。所以我想在request函数中返回recive函数的参数。我怎样才能做到这一点 ?
private Answer request(User user){ //perform request //wait for answer but how } public void recive(Answer answer){ //I want the answer parameter }
你不只是等待。您创建自定义侦听器:看这里 在 Java 中创建自定义事件 您需要使用您指定的参数调用此事件