I have three Integer
variables, where I am not allowed to change to primitive int
and I need to check if at least one of them have a value greater than 0. Is there a shorter / cleaner way to rewrite my code below:
Integer foo = // null or some value
Integer bar = // null or some value
Integer baz = // null or some value
boolean atLeastOnePositive = (foo != null && foo > 0) || (bar != null && bar > 0) || (baz != null && baz > 0)
return atLeastOnePositive;
isPositive
method is a bit of an overkill in your situation?