解释java中的(++ value%2 == 0 && ++ count <limit)

Sar*_*dra 5 java operator-precedence

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);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我得到的输出为

there
9
10
Run Code Online (Sandbox Code Playgroud)

解释算数是10 ....

Roh*_*ain 15

&&短路运营商.如果第一个表达式的计算结果为true,它将仅计算第二个表达式.

因为++value % 2 == 0是假的,所以它不评估第二个表达式,因此不会递增count.