0
I’m trying to do this matrix multiplication function but it’s giving error. Shows that the error is mult(int row, int column, int Linha2, int column2, int[][] matrix, int[][] matriz2) and says 'This method must Return a result of type int[][]'
public static int[][] mult(int linha, int coluna, int linha2, int coluna2, int[][] matriz, int[][] matriz2) {
if(matriz[0].length == matriz2.length){
int[][] matrizR = new int[linha][coluna2];
for(int i = 0; i < linha; i++){
for(int j = 0; j < coluna2; j++)
for(int k = 0; k < linha2; k++)
matrizR[i][j] = matriz[i][k] * matriz2[k][j];
}
return matrizR;
}
}
What should the function return if it doesn’t enter if? null? Add a return in case it doesn’t enter the if that will work.
– vmp
Not yet. I think it stops before you get to if, because the problem is in the function name and the variables.
– boltJu