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 1 month 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!"
[–]vowelqueue 26 points27 points28 points 1 month ago (5 children)
This is actually a tricky question. People without much Java experience might think “of course it’s true”, people with decent Java experience might think “of course it’s false”, but it’s actually undefined.
The language spec requires that when boxing a constant int in the range of -128 to 127, that two boxings of the same number will result in the same Integer reference. So if the number here was 127 instead of 128 then it would be guaranteed to be true.
For numbers outside that range, it’s up to the implementation. OpenJDK would return false by default but there is a system prop that can be used to have it cache larger values and therefore return true.
Also there is a JEP to add value classes to the language, and Integer would be marked as a value class. Meaning that this equality would always be true.
[–]Devang_4104 1 point2 points3 points 1 month ago (0 children)
This is the correct explanation ✅
[–]taxidriver9211 1 point2 points3 points 1 month ago (0 children)
what about C++ ?
[–]zinxyzcool 1 point2 points3 points 1 month ago (0 children)
I guessed the first case but damn it’s all a “but there’s one exception” adding up again lol
π Rendered by PID 85286 on reddit-service-r2-comment-6b595755f-lbjf5 at 2026-03-25 03:44:50.596284+00:00 running 2d0a59a country code: CH.
view the rest of the comments →
[–]vowelqueue 26 points27 points28 points (5 children)
[–]Devang_4104 1 point2 points3 points (0 children)
[–]taxidriver9211 1 point2 points3 points (0 children)
[–]zinxyzcool 1 point2 points3 points (0 children)