I am supposed to write a method that accepts 3 2-D arrays of This method should determine whether one of the matrices is the result of matrix addition of the other two.
public class Matrix {
    public static void main(String[]args){
        int [][] a = {{5,2,3},{4,1,6},{0,7,2}};
        int [][] b = {{1,2,3},{4,5,6},{0,1,2}};
        int [][] t = {{6,4,6},{8,6,12},{0,8,4}};
        System.out.println(add(a,b));
        System.out.println(check(a,b,t));
    }
    public static int [][] add(int[][]a,int[][]b){
        int i=0;
        int j=0;
        int[][] r = new int [3][3];
        while (i<a.length){
            r[i][j] = a[i][j] + b[i][j];
                i++;
                j++;
        }
        return r;
    }
    public static boolean check(int[][]a,int[][]b,int[][]t){
        int i = 0;
        int j = 0;
        while(i<t.length){
            if(t==add(a,b))
                return true;
        }
        return false;
    }
}
 
    