Skip to content

Commit 9e32e06

Browse files
committed
Fix
1 parent fae2ce7 commit 9e32e06

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/main/java/com/thealgorithms/misc/MatrixTranspose.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ private MatrixTranspose() {
2929
* @return The transposed matrix
3030
*/
3131
public static int[][] transpose(int[][] matrix) {
32-
if (matrix.length == 0 || matrix == null) {
32+
if (matrix == null || matrix.length == 0) {
3333
throw new IllegalArgumentException("Matrix is empty");
3434
}
3535

src/test/java/com/thealgorithms/misc/MatrixTransposeTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ public void testTransposeEmptyMatrix() {
5353
@Test
5454
public void testTransposeNullMatrix() {
5555
int[][] matrix = null;
56-
assertThrows(NullPointerException.class, () -> MatrixTranspose.transpose(matrix), "Expected IllegalArgumentException for null matrix.");
56+
assertThrows(IllegalArgumentException.class, () -> MatrixTranspose.transpose(matrix), "Expected IllegalArgumentException for null matrix.");
5757
}
5858
}

0 commit comments

Comments
 (0)