在一个方法中,我需要调用一些代码但是在方法的返回调用之后.我该怎么做呢?
// this call needs to happen after the return true call
xmlRpcClient.invoke("newDevices", listDeviceDesc);
return true;
Run Code Online (Sandbox Code Playgroud)
就像JohnHopkins所说的那样try{return true;}finally{yourCode},在调用return之后用来执行代码.但恕我直言,这是没有经过深思熟虑,我会改变该计划的设计.你可以告诉我们更多关于你的想法,了解你的方式吗?
你可能想做什么:
public void myMethod() {
return true;
}
if(myMethod()) {
client.invoke()
}
Run Code Online (Sandbox Code Playgroud)