What will be displyed after the following code is executed?

int x = 0;
System.out.print(x++==++x);
Explanation
- The value of x will be remembered as the left-hand side operand of an expression (i.e. 0)
- A post-increment will be performed after that (i.e., x will take a value of 1)
- A pre-increment will be performed then (i.e., x will take a value of 2)
- Only then the right-hand side operand will be obtained (i.e. 2) leading to a "0 == 2" comparison

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
тести з Java
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести