Java Array Convert to arrayOfDoubleToString(double[] array)

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

Description

Provides a string representation for a given double array.

License

Open Source License

Parameter

Parameter Description
array a parameter

Declaration

public static String arrayOfDoubleToString(double[] array) 

Method Source Code

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

public class Main {
    /**//from w w  w .  j  a  v a  2  s. c o  m
     * Provides a string representation for a given double array.
     * @param array
     * @return
     */
    public static String arrayOfDoubleToString(double[] array) {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        boolean firstIteration = true;
        for (int i = 0; i < array.length; ++i) {
            if (firstIteration) {
                firstIteration = false;
            } else {
                sb.append(",");
            }
            sb.append(String.format("%-3.3f", array[i]));
        }
        sb.append("]");

        return sb.toString();
    }
}

Related

  1. array_float_to_array_Float(float[] a)
  2. arrayFillNonAtomic(byte bArray[], short bOff, short bLen, byte bValue)
  3. arrayMoveWithin(Object[] array, int moveFrom, int moveTo, int numToMove)
  4. arrayOfIntToString(int[] array)
  5. arrayOfValuesToLookForIsEmpty()
  6. arrayToCamelCase(String[] nameArray, int start, int end)
  7. arrayToCSL(String[] vals)