order of evaluation - Explain if (++value % 2 == 0 && ++count < limit) in java -
public class andoperator { public static void main(string[] arg) { int value = 8; int count = 10; int limit = 11; if (++value % 2 == 0 && ++count < limit) { system.out.println("here"); system.out.println(value); system.out.println(count); } else{ system.out.println("there"); system.out.println(value); system.out.println(count); } } }
i getting output
there 9 10
explain how count 10....?
&&
short-circuit operator. evaluate 2nd expression if 1st expression evaluates true.
since ++value % 2 == 0
false, hence doesn't evaluate 2nd expression, , doesn't increment count
.
Comments
Post a Comment