Menu
Coddy logo textTech

Recap - 2D Arrays

Part of the Logic & Flow section of Coddy's Java journey — lesson 4 of 59.

challenge icon

Challenge

Easy

Create a method named processMatrix that takes a 2D array of integers as an argument and performs the following operations:

  1. Find the sum of all elements in the matrix.
  2. Find the maximum element in the matrix.
  3. Count the number of even elements in the matrix.

The method should return an array containing the sum, maximum element, and the count of even elements, in that order.

Try it yourself

// Write your code only inside the class. Do not write main() or any code outside this class.
class ProcessMatrix {
    public static int[] processMatrix(int[][] matrix) {
        // Write your code here
    }
}

All lessons in Logic & Flow