What a mess. Let me refactor things so I can see what's going on:
if (getNo() != null ? !compareNo(getNo(), b.getNo()) : getNo() != null)
{
return 100;
}
is the same as
Boolean mainCondition = getNo() != null ? !compareNo(getNo(), b.getNo()) : getNo() != null;
if (mainCondition)
{
return 100;
}
is the same as
Boolean mainCondition;
if (getNo() != null) {
mainCondition = !compareNo(getNo(), b.getNo());
} else {
mainCondition = getNo() != null;
}
if (mainCondition)
{
return 100;
}
but if getNo()
is null
, then we find ourselves in the else
condition, which will set mainCondition
to false
, so we will not return
, i.e. a simpler way to write this is:
if (getNo() != null) {
if (!compareNo(getNo(), b.getNo()))
{
return 100;
}
}
or
if (getNo() != null && !compareNo(getNo(), b.getNo())) {
return 100;
}
The answer is yes: if !compareNo(getNo(), b.getNo())
is true, then the original statement will return 100
.
As for what happens to the part after the :
, it will not be evaluated unless getNo()
is null, however if getNo()
is indeed null
, then we already know the outcome, so it's quite redundant to include it there.