Hi
First of all
Integer x=0;
x++;//this is possible as
java 5 does autoboxing
here
1.z=0
preincrement on x(++x),so it increments x and y before checking >2
it will be (1>2) || (1>2)
since if condition is false,it wont execute x++;
now x=1 and y=1
2.z=1
it will be (2>2)||(2>2)
condition false
now x=2 y=2
3.z=2
Its important now.
if || is used ,then if the first condition is true,then it wont even look at the second one (++y>2)
so it preincrements x which will be 3
If condition satisfied.
x++;
Now x=4 y=2
4.z=3
Same thing happens as z=2
At the end x=6 y=2
5.z=4
Same thing happens as z=2
At the end x=8 y=2
gets out of the loop and prints 8 2
Thanks
Praveen SP