This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Yeah tricky !! The 1st line explains the others. The expression a---b will be evaluated as (a--) - b which is 4 - 6 = -2. BUT THEN a is decremented (a--) and the value of a is now 3. The rest is now straightforward: The second expression gives a + (-b) which yields 3 + (-6) = -3. The third expression gives a - (-b) which yields 3 - (-6) = 9 And the last expression gives a + (+b) which yields 3 + (+6) = 9 I think the trickiest part was the first expression with the three minus signs one after another (---). Here is the thing, the Java parser always takes the longest accepted token when parsing, that is, --- when parsed gives the token -- (decrement operator) and - (minus). Please change your name according to the Javaranch Naming Policy HIH [ January 17, 2002: Message edited by: Valentin Crettaz ]