Hi,
This is because you are assiging x the value of x itself which is 1 i.e before incrementing.
This is post-increment so it is evaluated at last.
Instead if you just write "x++;" then you can get the expected output i.e 2.
There is one very nice explaination abt
post/pre-increment on Javaranch.
regds,
Amit