Recap - 2D Arrays
Part of the Logic & Flow section of Coddy's Java journey — lesson 4 of 59.
Challenge
EasyCreate a method named processMatrix that takes a 2D array of integers as an argument and performs the following operations:
- Find the sum of all elements in the matrix.
- Find the maximum element in the matrix.
- 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
1Multi-dimensional Arrays
2D Arrays BasicsAccessing 2D Array ElementsNested Loops with 2D ArraysRecap - 2D ArraysMatrix Addition & SubstractionJagged Arrays3D Arrays And BeyondCommon 2D Array PatternsRecap - All About Arrays2HashMap Part 1
What is a HashMap?Declare a HashMapAccessing ValuesCheck If Key ExistsModifying DictionariesRecap - HashMap