I have two methods names as sendSData() and sendCData() in MyClass.
class MyClass
{
public void sendSData()
{
// Receiving Response from database
}
public void sendCData()
{
// send C Data
}
}
I'm calling these two method from main method
public static void main(String ... args)
{
MyClass obj=new MyClass();
obj.sendSData();
obj.sendCData();
}
It is possible for me to send sendCData request after if and only if I got success response from sendSData() method.
How can I achieve this in java?
sendData() publishing data to server . if I get success response from server then it will be possible for me to send sendCData(). I'm usung pub/sub model. I'm not calling any web service or REST service. for receiving respose I have separate subscriber
public boolean sendSData() {
// handle whether or not the function returns true or false
return true;
}
public static void main(String ... args) {
MyClass obj=new MyClass();
if (obj.sendSData()) {
obj.sendCData();
} else {
// obj.sendSData() did not successfully respond
}
}
With the above code obj.sendCData() will only run if sendSData() returns true (successfully responded).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With