public static void printMatrix(double[][] matrix) {
for (double[] row : matrix) {
for (double element : row) {
System.out.printf("%5.1f", element);
}
System.out.println();
}
}
Function Call
printMatrix(new double[][]{2,0,0},{0,2,0},{0,0,3}});
Output:
2.0 0.0 0.0
0.0 2.0 0.0
0.0 0.0 3.0
In console: