Java Program to transpose matrix

Converting rows of a matrix into columns and columns of a matrix into row is called transpose of a matrix.

Let's see a simple example to transpose a matrix of 3 rows and 3 columns.

Test it Now

Output:

Printing Matrix without transpose:
1 3 4 
2 4 3 
3 4 5 
Printing Matrix After Transpose:
1 2 3 
3 4 4 
4 3 5 

Java Program to display transpose matrix

Let's see another example where we are displaying transpose of a matrix. Here, we are not creating another matrix.

Test it Now

Output:

Printing Matrix without transpose:
1 3 4 
2 4 3 
3 4 5 
Printing Matrix After Transpose:
1 2 3 
3 4 4 
4 3 5 

Java program to transpose matrix (Another way)

You can also use a method where values of matrix are not predefined. Here, user has to put the values as input.

Output:

Use image MatrixTranspose
Next TopicJava Programs


Latest Courses