Skip to content

Commit 10932cc

Browse files
author
Egoscio
authored
Comparing Matrix size before content size.
1 parent 067e39d commit 10932cc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

DataStructures/Matrix/Matrix.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,14 @@ public Matrix multiply(Matrix other) throws RuntimeException {
211211
* @return boolean
212212
*/
213213
public boolean equals(Matrix other) {
214+
if (this.getRows() != other.getRows() || this.getColumns() != other.getColumns())
215+
return false;
216+
214217
for (int i = 0; i < this.data.length; i++)
215218
for (int j = 0; j < this.data[0].length; j++)
216219
if (this.data[i][j] != other.data[i][j])
217220
return false;
218-
221+
219222
return true;
220223
}
221224

0 commit comments

Comments
 (0)