java operator ++ problem

Viewed 5145

I wonder why first code output is 000 while the second one is 123

first one:

int z=0;
    while(z<4)
    {
       z=z++;
       System.out.print(z);

    }

second one :

int z=0;
int x=0;
    while(z<5)
    {
       x=z++;
       System.out.print(x);

    }

what is the different between these two codes , why the first block do not increase the value of the z ?

9 Answers
Related