Java Array Deep to String deepToString(double[][] array)

Here you can find the source of deepToString(double[][] array)

Description

deep To String

License

Apache License

Declaration

public static String deepToString(double[][] array) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String deepToString(double[][] array) {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        for (double[] arr : array) {
            sb.append("[");
            for (double a : arr) {
                sb.append(String.format("%10.3g, ", a));
            }/*from   w w  w .  j ava2s  .c o  m*/
            sb.append("], ");
        }
        sb.append("]");
        return sb.toString();
    }

    public static String toString(double[] array, String formatString) {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        for (int i = 0; i < array.length; i++) {
            sb.append(String.format(formatString, array[i]));
            if (i < array.length - 1) {
                sb.append(", ");
            }
        }
        sb.append("}");
        return sb.toString();
    }
}

Related

  1. deepToString(int[] values)
  2. deepToString(Object[] array)