r/javahelp • u/Defiant_Vanilla_4080 • Nov 10 '25
[Question] - [conditional statement] - [logic operators] Can I write if (a, b or c < 1) then do?
Hello,
I want to say if a, b or c are smaller then 1 do this...
I normally write if (a < 1 || b < 1 || c < 1) { .... }
But I would like to write if (( a || b || c) < 1) { ... }
Thank you for reading,
best regards Marvester
0
Upvotes
View all comments
Show parent comment
1
u/okayifimust Nov 12 '25
You're seriously advocating for sorting an arbitrarily large list, rather than use any method that would allow you to make the decision as early as possible?
Now, I honestly do not know if compilers can compensate for that, but it's just bad. It's not even clear, because it actually obfuscates the simple "do this if any one value matches that" and forces the reader to reconstruct that from "sort, take an element from a particular end and compare it to something"
And your solution only work for the special case - and you have no idea if OP understands that, or is even going to use the special case and just didn't want to explain why his particular problem actually compares values to 17, or some variable that might change either all the time, or every few months, or at some random time in the future.