Increment and decrement operators in Java

JavaObject Oriented ProgrammingProgramming

in this expression a > b || a != b && a == b++, according to operator precedence && will work first before ||. So a != b && a == b++ will return false and after that whole expression returns true as a>b is true. So result is true but b and a will not be changed and take the values 2 and 1 always because a==b++ is checking for equality not assigning the value of b++ to a as there is ==(relational operator) not =(assignment operator).

raja
Published on 03-May-2018 06:42:41
Advertisements