This week's book giveaway is in the Game Development forum. We're giving away four copies of Badass: Making Users Awesome and have Kathy Sierra on-line! See this thread for details.

Hello, I am totally confused with operator precedence. It is said that expr++ has higher precdence than ++exprlink. What does this mean? Let me come down to 2 questions with examples 1. int x = -1; int y = ++x + x++; Will the above line be executed as 1 + -1 = 0 or as 0 + 0 = 0. Because when i try to execute it i will always get the answer as 0 but i don't know which is first evaluated is it ++x or x++. please help!!! 2. Unary operators are evaluated in right to left order. What does this mean... y = x+++x; is it equivalent to (x++) + x or x + (++x) . The answer is same in both cases. I hope I am clear in my questions. Thank you Lalitha

Originally posted by Lalitha Chandran: Hello, 2. Unary operators are evaluated in right to left order. What does this mean... y = x+++x; is it equivalent to (x++) + x or x + (++x) . The answer is same in both cases. I hope I am clear in my questions. Thank you Lalitha

In JLS, it is mentioned that "While translating Unicode stream into sequence of input elements(white spaces, comments and tokens), the longest possible translation is used at each step. As such x+++x, will always be evaluated as (x++) + x