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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -