a java application program to multiply two matrices A and
B and output the product matrix C. Matrix A must have the same number of columns as matrix B has rows. The maximum matrix sizes are 5
Try this code, pastit as private in your clase or as a static method in other one.
private int matrixMult(int m1, int m2)
int m3 = new int[m1.length][m2.length];
m3[i][j] += m1[i][k]*m2[k][j];
the null happens when the sizes of the matrix are not compatible.
n m n m
as you can see if m in a has the same size of n in b.
the calculation can proceed.
n in a and m in b define the new dimensions of the future matrix.
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Participation.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.