Here you can find the source of toString(double[] array)
public static String toString(double[] array)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; public class Main { private static final DecimalFormat df = new DecimalFormat("#.####"); public static String toString(double[] array) { String display = "["; for (double val : array) { display += val + ", "; }/* ww w.jav a 2 s . com*/ display = display.substring(0, display.length() - 2); display += "]"; return display; } public static String toString(List<String> list) { String display = "["; for (String val : list) { display += val + ", "; } if (display.length() > 2) { display = display.substring(0, display.length() - 2) + "]"; } else { display += "]"; } return display; } public static String toString(TreeMap<Double, Double> map) { String display = "["; for (Map.Entry<Double, Double> entry : map.entrySet()) { display += nice(entry.getKey()) + " : " + nice(entry.getValue()) + ", "; } display = display.substring(0, display.length() - 2) + "]"; return display; } public static String toString(HashMap<String, Long> map) { String display = "["; for (Map.Entry<String, Long> entry : map.entrySet()) { display += entry.getKey() + " : " + entry.getValue() + ", "; } display = display.substring(0, display.length() - 2) + "]"; return display; } private static double nice(Double val) { return nice(val.doubleValue()); } private static double nice(double val) { return Double.valueOf(df.format(val)); } }