This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff 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 ]