Here you can find the source of matrixToString(int[][] m)
Parameter | Description |
---|---|
m | A matrix to get its formatted string representation |
public static String matrixToString(int[][] m)
//package com.java2s; //License from project: Open Source License public class Main { /**//from www . j a v a 2 s . c o m * Creates and returns a formatted string represenation of the input matrix m * @param m A matrix to get its formatted string representation * @return A formatted string of the input matrix: [[a, b, c], [d, e, f]] */ public static String matrixToString(int[][] m) { String str = ""; for (int i = 0; i < m.length; i++) { str += ((str.length() > 0) ? ",\n" : "") + "["; for (int j = 0; j < m[0].length; j++) str += m[i][j] + ((j < m[0].length - 1) ? ", " : ""); str += "]"; } return str; } }