is Matrix Equal to another Matrix - Java java.lang

Java examples for java.lang:Math Matrix

Description

is Matrix Equal to another Matrix

Demo Code


//package com.java2s;

public class Main {
    public static boolean isMatrixsEqual(Integer[][] m1, Integer[][] m2) {

        if (m1.length != m2.length || m1[0].length != m2[0].length)
            return false;

        for (int i = 0; i < m1.length; i++) {
            for (int j = 0; j < m1[0].length; j++) {
                if (!m1[i][j].equals(m2[i][j]))
                    return false;
            }/*from   ww  w .j av  a 2  s . com*/
        }

        return true;
    }
}

Related Tutorials