Reputation: 5637
Why the following method always return false for the below value. Do I confuse with somethings??
public boolean isTwoWay(Detail detail) {
return (detail.isExchange && detail.isTwoWay && !detail.isIVR);
}
which data contain following
detail.isExchange = true;
detail.isTwoWay = true;
detail.isIVR = false;
but it return false instead of true
Upvotes: 2
Views: 76
Reputation: 4418
I have tried with that and its print true always.
boolean isExchange = true;
boolean isTwoWay = true;
boolean isIVR = false;
System.out.println(isExchange && isTwoWay && !isIVR);
Upvotes: 0
Reputation: 124824
The only way the method will return false is if one of your assumptions is wrong:
detail.isExchange = true; detail.isTwoWat = true; detail.isIVR = false;
Rest assured, this kind of oversight happens to programmers all the time, including the best of us.
Put a breakpoint where you receive false instead of your expected true, and verify your assumptions.
Upvotes: 1