I expected post-increment and pre-increment of a variable and assignment of the result to itself to work a bit differently. But while the latter works as expected, the former runs as infinite while loop. Could someone please point out what i am missing here?
int y = 0;
int z = 4;
while(y<z)
{
System.out.println(y);
y =y++;//this prints 0 infinite times, shouldn't why be assigned values 0,1,2,3 with each pass?
//y =++y;//this works as expected
}
Thank you