Java Double Array to String doubleArrayToString(double[] array)

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

Description

Creates a string representation of the given array of type double[] (this representation can be parsed using the method parseDoubleArray).

License

Open Source License

Parameter

Parameter Description
array the array

Return

string representation of the given array

Declaration

public static String doubleArrayToString(double[] array) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//  w ww .  j  a v a 2s. c  o m
     * Creates a string representation of the given array of type double[] (this representation
     * can be parsed using the method parseDoubleArray).
     * @param array the array
     * @return string representation of the given array
     */
    public static String doubleArrayToString(double[] array) {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        for (double a : array) {
            sb.append(a).append(", ");
        }
        if (sb.lastIndexOf(", ") != -1)
            sb.delete(sb.lastIndexOf(", "), sb.length());
        sb.append("]");
        return sb.toString();
    }
}

Related

  1. doubleArrayToString(double[] descriptor, char separator)
  2. doubleArrayToStringArray(final double[] line)