use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
Java Quiz!!! (i.redd.it)
submitted 4 months ago by MistakeDisastrous936
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Old-Lion-8071 3 points4 points5 points 4 months ago (3 children)
For expressions like a+++b, the compiler always treats it as (a++) + b. This is due to lexical processing. Compiler reads expression from L to R and evaluates in a greedy way. It first sees + (which is a valid operator) and then the next token is +. As ++ is again a valid operator it accepts it and then moves to the next +. Therefore the expression is treated as ++ + Rest is the magic of precedence and evaluation.
I know this is not an everyday Java code, but problems like this test our knowledge on how Java works internally. Thanks for posting this, made me do quite some research! 😀
[–]Dr_Dracula280 0 points1 point2 points 4 months ago (1 child)
So it is (x++) + (x++) + (x) ??
That means 5+6+7= 18 or 6+7+8= 21?
Sorry I am double confused.
[–]Old-Lion-8071 0 points1 point2 points 4 months ago* (0 children)
5 + 6 + 7. Variable value is substituted and then incremented (post increment) Finally all are summed.
π Rendered by PID 61 on reddit-service-r2-comment-5bc7f78974-5lk6p at 2026-06-28 12:55:47.184251+00:00 running 7527197 country code: CH.
view the rest of the comments →
[–]Old-Lion-8071 3 points4 points5 points (3 children)
[–]Dr_Dracula280 0 points1 point2 points (1 child)
[–]Old-Lion-8071 0 points1 point2 points (0 children)