Clarification regarding Postfix Increment Operator ++ :java

后端 未结 5 535
情深已故
情深已故 2020-12-17 04:30
int i = 0;
boolean b = true;
System.out.println(b && !(i++ > 0))

When I compile the above code I

5条回答
  •  星月不相逢
    2020-12-17 04:52

    b && !(i++ > 0)
    

    i++ is post increment so value of i here is still 0

    0>0 false

    b && 1 is true(since !(0) is 1)

    So you are getting true.

提交回复
热议问题