Plz explain this JAVA code. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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]