x++ uses post increment and it means it increments its value AFTER the statement which x is in. So x still equals -1. Later in the same statement will get to a ++x, which increments x on the spot, so now x=0. So now y = 0. But don't forget that x now = 1 because we had a post increment operation in the statement, so x got incremented after the statement.
I think that was the trickiest part, the rest should be ok to understand.
First We need to know one thing..Individual Static BLock with Variable X is not accessible for Main().. so X=0 and y=0 in main()
before coming to this following exp x = -1 and y = 0 y = x++ + ++x; in this exp first x++ will be executed -> x++ -> x= -1 + 1 -> x= 0 in this exp next ++x will be executed -> ++x -> x = 0 + 1 -> x = 0 next we will go for total exp
but what i have make the final conclusion is x+++++x is equalant to (x++)+(++x); and not =((x++)++)+x and we can't write x+++++x as we have to put space like x++ + ++x as its giving error in the link above ?
any way do post ur comments regards [ June 11, 2005: Message edited by: amit taneja ]