formats a double array to a string with spaces between values - Java java.lang

Java examples for java.lang:double Array

Description

formats a double array to a string with spaces between values

Demo Code


//package com.java2s;

public class Main {
    /**/*  w  ww .  j  a v a  2  s  .  co m*/
     * formats a double array to a string with spaces between values
     * @param arr
     * @return
     */
    public static String doubleArrayToString(double[] arr) {

        String ret = "";

        int i = 0;

        for (double d : arr) {
            if (d > 0.0) {
                ret += " " + i + ":" + d;
            }

            i++;
        }

        return ret;

    }
}

Related Tutorials