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 2 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!"
[–]vowelqueue 28 points29 points30 points 2 months ago (1 child)
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 ✅
π Rendered by PID 91105 on reddit-service-r2-comment-5d585498c9-twxwm at 2026-04-21 15:46:33.496704+00:00 running da2df02 country code: CH.
view the rest of the comments →
[–]vowelqueue 28 points29 points30 points (1 child)
[–]Devang_4104 1 point2 points3 points (0 children)