← Unit 4 · all exercises
Saved in this browser only

Count the even numbers

Return how many of the numbers in the array are even. Zero counts as even.

int countEvens(int[] values)

Solution.java
Loading editor…
Results

Examples

  • Solution.countEvens(new int[]{1, 2, 3, 4}) → 2
  • Solution.countEvens(new int[]{1, 3, 5}) → 0

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