This class sums a 2D matrix.
To use this class, just make a simple object of
Find2DMatrixSumclass and callfindSumOfMatrix()method which returns you anintwhich represents the sum of the matrix. If the sum can exceed theintrange, you can usefindLongSumOfMatrix()to get thelongnumber as sum.
public int findSumOfMatrix() {
// returns sum of matrix
}public int findLongSumOfMatrix() {
// returns long sum of matrix
}Example code, for understanding:
public static void main(String[] args){
int[][] arr = new int[][]{
{1, 2, 3},
{4, 5, 6},
{7, 8, 9}
};
Find2DMatrixSum mSum = new Find2DMatrixSum(arr);
System.out.println(mSum.findSumOfMatrix()); // 45
}