Java Matrix to String toString(int[][] a)

Here you can find the source of toString(int[][] a)

Description

to String

License

Open Source License

Declaration

public static String toString(int[][] a) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    public static String toString(int[][] a) {
        StringBuilder result = new StringBuilder("[");
        for (int i = 0; i < a.length; i++) {
            result.append(Arrays.toString(a[i]));
            if (i < a.length - 1)
                result.append(',');
        }// w  ww  .  j av  a 2  s . com
        result.append(']');
        return result.toString();
    }

    public static String toString(double[][] b) {
        StringBuilder result = new StringBuilder("[");
        for (int i = 0; i < b.length; i++) {
            result.append(Arrays.toString(b[i]));
            if (i < b.length - 1)
                result.append(',');
        }
        result.append(']');
        return result.toString();
    }

    public static String toString(boolean[][] b) {
        StringBuilder result = new StringBuilder("[");
        for (int i = 0; i < b.length; i++) {
            result.append(Arrays.toString(b[i]));
            if (i < b.length - 1)
                result.append(',');
        }
        result.append(']');
        return result.toString();
    }
}

Related

  1. matrixToString(String[][] m)
  2. toString(double[][] A)
  3. toString(double[][] array)
  4. toString(double[][] data)
  5. toString(int partition[][])
  6. toString(int[][] matrix)
  7. toString(Object[][] arr)