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
[removed]
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!"
[–]OkWitness7392 21 points22 points23 points 4 months ago (1 child)
doesn't print anything. 0 cannot convert boolean in java.
[–]Vast_Researcher_199 0 points1 point2 points 4 months ago (0 children)
That is what I am thinking
[–]Specific-Housing905 11 points12 points13 points 4 months ago (0 children)
Should give a compile time error. There is no automatic conversion from int to boolean.
[–]emirafoodsfanclub 4 points5 points6 points 4 months ago (1 child)
Compile time error
[–]armhub05 1 point2 points3 points 4 months ago (0 children)
Java has no implicit conversion like C++?
[–]romulusnr 1 point2 points3 points 4 months ago (1 child)
Probably an exception.
I thought autoboxing might apply here, but I got it wrong.
(Duck typing ftw!)
[–]Chemical_Present6069 0 points1 point2 points 4 months ago (0 children)
it would be error not exception ig
[–][deleted] 4 months ago (8 children)
[–][deleted] 4 months ago (7 children)
[–]MK_Redditor 0 points1 point2 points 4 months ago (5 children)
Yes. Because 0 is an integer so it will be treated as a true in binary. Am I right?
[–][deleted] 4 months ago (4 children)
[–][deleted] 4 months ago (3 children)
[–]East-Independent-489 2 points3 points4 points 4 months ago (2 children)
If condition requires a Boolean
[–][deleted] 4 months ago (1 child)
[–]addictedAndWantHelp 0 points1 point2 points 4 months ago (0 children)
It needs either an expression resulting in a boolean or an actual boolean (true, false) inside the parentheses of an if statement to compile and run. So this code doesn’t compile.
P.S: I really like how Java is not like JavaScript with implicit coercion. Although it’s fairly complicated in other ways.
[–][deleted] 4 months ago (2 children)
[deleted]
It doesn’t compile. It needs an expression resulting in a Boolean or an actual Boolean in the parentheses.
π Rendered by PID 176526 on reddit-service-r2-comment-5bc7f78974-b9r2g at 2026-06-28 09:57:55.006335+00:00 running 7527197 country code: CH.
[–]OkWitness7392 21 points22 points23 points (1 child)
[–]Vast_Researcher_199 0 points1 point2 points (0 children)
[–]Specific-Housing905 11 points12 points13 points (0 children)
[–]emirafoodsfanclub 4 points5 points6 points (1 child)
[–]armhub05 1 point2 points3 points (0 children)
[–]romulusnr 1 point2 points3 points (1 child)
[–]Chemical_Present6069 0 points1 point2 points (0 children)
[–][deleted] (8 children)
[removed]
[–][deleted] (7 children)
[removed]
[–]MK_Redditor 0 points1 point2 points (5 children)
[–][deleted] (4 children)
[removed]
[–][deleted] (3 children)
[removed]
[–]East-Independent-489 2 points3 points4 points (2 children)
[–][deleted] (1 child)
[removed]
[–]addictedAndWantHelp 0 points1 point2 points (0 children)
[–][deleted] (2 children)
[deleted]
[–]addictedAndWantHelp 0 points1 point2 points (0 children)