I can not understand why the answer will be one. Tell me please.

int x = 0; System.out.println(++x + --x); 

    1 answer 1

    ++x - means that unit will be added to x immediately and we will use the already changed value; similarly for --x .

    1. At the first step, x = 0 ;

    2. After ++x x = 1 ;

    3. After --x x = 0 ;

    4. 1 + 0 = 1.

    • Exactly, thank you very much, I will continue to be more careful - Arthur Yatsun