← Unit 4 · all exercises
Saved in this browser only

Are they all positive

Return true when every number in the array is above zero. An empty array counts as true — there is nothing to contradict it.

boolean allPositive(int[] values)

Solution.java
Loading editor…
Results

Examples

  • Solution.allPositive(new int[]{1, 2, 3}) → true
  • Solution.allPositive(new int[]{1, -2}) → false

There are also 3 hidden tests you can't see. Solve the problem, not the examples.