We can multiply two matrices in java using binary * operator and executing another loop. A matrix is also known as array of arrays. We can add, subtract and multiply matrices.

Note : In matrix multiplication, the number of columns of first matrix must be equal to the number of rows of second matrix. else my code will print "It cant be Multiplied".

Multiplication of two Matrices using JAVA

To multiply we need to enter following information 1st :

Number of rows and columns of 2 matrices, and their value depending on then number of rows and columns. To understand more please remove comments "//" before "System.out.print".

Sample Input :

2 2
2 2
1 1
1 1
1 1
1 1

Sample output :

2 2
2 2

Note: This is how I implemented and maybe there are some room for improvement. If you have any suggestion please let me. Thanks <3