+ 1

Plz explain this JAVA code.

Explain this code: πŸ‘‡πŸ‘‡πŸ‘‡ int x = 1; x += x++; System.out.print(x);

22nd Apr 2021, 1:07 PM
Jawad Shopnil
Jawad Shopnil - avatar
2 Answers
+ 7
Jawad Shopnil int x = 1; x += x++; x = x + x++; x = 1 + 1; x = 2;
22nd Apr 2021, 1:11 PM
AΝ’J
AΝ’J - avatar
+ 3
Remember x++ first uses the value then increment the value
22nd Apr 2021, 1:17 PM
Atul [Inactive]