# Java Program to Find Inverse of a Matrix

Here you will get java program to find inverse of a matrix of order 2×2 and 3×3.

We can find inverse of a matrix in following way.

• First find the determinant of matrix.
• Finally divide adjoint of matrix by determinant.

Image Source

Below I have shared program to find inverse of 2×2 and 3×3 matrix.

## Java Program to Find Inverse of a Matrix

### 2×2 Matrix

Output

Enter elements of matrix row wise:
4 7
2 6

determinant = 10.0

Inverse of matrix is:
0.6 -0.7
-0.2 0.4

### 3×3 Matrix

Output

Enter elements of matrix row wise:
1 2 3
0 1 4
5 6 0

determinant = 1.0

Inverse of matrix is:
-24.0 18.0 5.0
20.0 -15.0 -4.0
-5.0 4.0 1.0

Comment below if you have any queries related to above program to find inverse of matrix in java.

### 3 thoughts on “Java Program to Find Inverse of a Matrix”

1. Hmmmmm.

I may try to make an inverse. Check the loop – it has %3 (modulo 3) many places. And it has loops going up to and not including 3. This may be a part of it. Furthermore we may need to see how matrix multiplication is done with 3, 4 and 5 dimensions – then that may give a clue..

One day … Hmmmm

1. Thank you so much for providing such software snippets. It is a great help for us who are maybe not THAAAAAT super experts in mathematics.

If you on the other hand, one day, need assistance on algorithms, feel welcome.