If you're writing anything like foo = foo++, you're doing it wrong. In general, if you see any expression like x = x++ + ++x; something is seriously wrong. It's impossible to predict how expressions of that sort are evaluated. In languages like C, such expressions can be evaluated as the implementer desires.
I'd strongly recommend playing around with the ++ operator because you're bound to encounter it when you read code.
As others have pointed out, x++ is the postfix operator and ++x is a prefix operator.
int x = 0;
int y = x++; // y=0, x=1
int z = ++x; // z=2, x=2
Note that the values of y, z and x are what they are only after the expression is evaluated. What they are during execution is undefined.
So if you see code like foo(x++, ++x, x), run for the hills.
Your own problem is more succinctly written:
for (int z=0; z<4; ++z) {
System.out.print(z);
}
The above code has the advantage that the variable z is scoped within the for loop, so it won't accidentally collide with some other variable.
01234