Closed Egoscio-zz closed 5 years ago
would this fix it?
public boolean equals(Matrix other) { //return this == other; return this.equals(other); }
That's going to give you a StackOverflowError
exception because you're recursively defining the equals function.
The matrix class and the tests written for it only support shallow comparison. In other words, comparisons only verify whether two matrices have the same reference rather than actually comparing each element in the matrix.
The above equality should equate to
true
, since a matrix plus the zero matrix is itself (identity property of matrix addition), but instead, it equates tofalse
. Deep comparison is necessary, in the same way a deep copy of the data is made in the matrix constructor.