In this case Assignment is done first ie x gets the value 0 than the postincrement operator increments x. As x is assigned value 0 than it gets incremented to 1 which is not assigned to x so it prints 0.
Now in the second case
int x=0; x++; System.out.println(x);
here no assignment is done but we are directly incrementing x using postincrement operator hence x value becomes 1 and we get output as 1.
Hi dhwani, As you mentioned it get incremented what do you mean by it (isit x?) i just want to know where the inceremented value will be stored. and also x=x++ means x=x=x+1; is this right ? could please explain in more detailed way? Since after increment only i am trying to print the x value.