Can anybody help me on following issue:
I have code like:
if(cond1 && cond2 && .. && cond10)
Here, cond1 are expensive operations whose output is Boolean.
Now my question is what JAVAC will do, when cond2 output is false. Specifically, is it goes evaluate cond3 ‘s output or stops evaluation ?
More illustratively,
if(cond1 && cond2 && .. && cond10)
//do this
and
if(cond1){
if(cond2){
.
.
.
if(cond10){
//do this
}
are same in java (in case of execution way) ?
The
&&operator always short-circuits onfalse. Condition 3 will only be evaluated if conditions 1 and 2 aretrue.