+ 3
Why output of this code is 1 not 2 ?
int x = !(1>0) ? 0:1; // here x = 1 x = x++;. // After this statement why x= 1 not 2 ? System.out.print(x); Why post increment is not working ??
2 Réponses
+ 2
The post increment is working.
This could explain whats going on:
1 > 0 is true and its value is 1.
The ! operator reverses the output of the previous expression shown in parentheses.
So it means that the value is now 0.
Adding increment to it becomes 1.
Thanks for your question and happy coding.
0
Ok thank you 👍