+ 1

can’t seem to understand.

i find understanding x++ and ++x very confusing, anyway of explaining and memorising it?

18th Feb 2019, 11:52 AM
Zauks
Zauks - avatar
1 Odpowiedź
+ 3
As far as I know, ++x increments the value of x and then returns x. x++ returns the value of x and then increments. For example: x = 3, y = 3 - System.out.println(++x) --> 4 - System.out.println(x) --> 4 - System.out.println(y++) --> 3 - System.out.println(y) --> 4 As you can see in the first case, It first increases the value and then returns. On the other hand, x++ returns first the value and then increments.
18th Feb 2019, 12:57 PM
MrAir
MrAir - avatar