shantanu shantanu - 1 year ago 76
Java Question

JAVA : Order of executaion in "and"(&&) condition

I have basic question regarding order of execution with "and" operator.

if( ifFun1() && ifFun2() ) {
//Do somethig

bool ifFun1() {...}
bool ifFun2() {...}

In above code block,
if isFun1()
is returning false, is it guaranteed that
will never be executed. Or at compiler level their might be some optimization which might led to execution of
as well.



Answer Source

isFun2() will never execute if isFun1() returns false;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download