This week's book giveaway is in the Design forum. We're giving away four copies of Building Microservices and have Sam Newman on-line! See this thread for details.

System.out.println(y+++x); This will be interpreted as ((y++)+x) This is because the compiler will parse the expression from left to right. postfix ++ operator is left associative so first two + out of +++ will be associated with y. the one + left will be a binary operator between y++ and x. But the output will be 3 as it will be interpreted as 1+2. This is because the value of y will be 1 in this expression. After using the value of y in the expression y will be incremented.

Now x = 2 and y = 2 System.out.println(y+ ++x); This one is simple. It will work as 2+3. Here the value of x will be first incremented and then used in the expression.

Now x = 3 and y = 2 System.out.println(++x); This one is again easy. The value of x will be incremented from 3 to 4 and then displayed.

Now x = 4 and y = 2 System.out.println(x++); In this one the value of x will be used in the expression and then incremented. So 4 will be displayed and then the value of x will become 5.

I think you have confusion between pre and postfix increment operators. Consult some book for this or google it...