Java Matrix to String matrix_toString(int[][] matrix)

Here you can find the source of matrix_toString(int[][] matrix)

Description

matrito String

License

Creative Commons License

Declaration

public static String matrix_toString(int[][] matrix) 

Method Source Code

//package com.java2s;
//<div>Icons made by <a href="http://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>

public class Main {
    public static String matrix_toString(int[][] matrix) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < matrix.length; i++) {
            sb.append("[ ");
            for (int j = 0; j < matrix[0].length; j++) {
                sb.append(matrix[i][j] + " ");
            }/*from  w w w.  ja  v  a 2s.co  m*/
            sb.append("]\n");
        }
        return sb.toString();
    }
}

Related

  1. Array2DToString(double[][] array)
  2. array2DToString(int[][] grid)
  3. formatTable(String[][] table)
  4. matrix2string(int[][] matrix)
  5. matrixToString(double[][] matrix, int digit, String[] names)
  6. matrixToString(float[][][] matrix)
  7. matrixToString(int[][] m)
  8. matrixToString(int[][] matrix, String sep)