Why does this
int x = 2;
for (int y =2; y>0;y--){
System.out.println(x + \" \"+ y + \" \");
x++;
}
prints the s
They DON'T behave the same. The construct with i++ is slightly slower than the one with ++i because the former involves returning both the old and the new values of i. On the other side, the latter only returns the old value of i.
Then, probably the compiler does a little magic and changes any isolated i++ into a ++i for performance reasons, but in terms of raw algorithm they are not strictly the same.