Here you can find the source of arrayToString(String format, double[] array)
public static String arrayToString(String format, double[] array)
//package com.java2s; /*Copyright (C) 2012 Lars Andersen, Tormund S. Haus. larsan@stud.ntnu.no/*from w w w .j a v a 2 s .com*/ tormunds@stud.ntnu.no EASY is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. EASY is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with EASY. If not, see <http://www.gnu.org/licenses/>.*/ import java.io.PrintWriter; import java.io.StringWriter; public class Main { public static String arrayToString(String format, double[] array) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); pw.print("["); if (array.length > 0) pw.printf(format, array[0]); for (int i = 1; i < array.length; i++) { pw.print(", "); pw.printf(format, array[i]); } pw.print("]"); return sw.toString(); } }