How can I print out a simple int [][] in the matrix box format like the format in which we handwrite matrices in. A simple run of loops doesn\'t apparently work. If it helps
public static void printMatrix(double[][] matrix) { for (double[] row : matrix) { for (double element : row) { System.out.printf("%5.1f", element); } System.out.println(); } }
printMatrix(new double[][]{2,0,0},{0,2,0},{0,0,3}});
2.0 0.0 0.0 0.0 2.0 0.0 0.0 0.0 3.0