On it’s own there is no difference.
x++;
and
++x;
Are the same.
The difference comes when you’re immediately using x.
int x = 1;
int y = x++;
has y being 1.
int x = 1;
int y = ++x;
has y being 2.
That’s what pre and post increment means.
In post increment, you do whatever, and then you increment.
In pre increment, you increment, and then you do whatever.
Latest Answers