Here you can find the source of doublesToStrings(final double... numbers)
public static String[] doublesToStrings(final double... numbers)
//package com.java2s; /*/* w ww . j a v a 2 s. co m*/ * Copyright 2009-2015 Hewlett-Packard Development Company, L.P. * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. */ import java.text.DecimalFormat; public class Main { public static String[] doublesToStrings(final double... numbers) { if (numbers == null) { return null; } final String[] strings = new String[numbers.length]; int index = 0; for (final double number : numbers) { strings[index++] = doubleToString(number); } return strings; } public static String doubleToString(final double number) { final double abs = Math.abs(number); final DecimalFormat format; if (abs < 100.0) { format = new DecimalFormat("#.#####"); } else if (abs < 1000.0) { format = new DecimalFormat("#.####"); } else if (abs < 10000.0) { format = new DecimalFormat("#.###"); } else if (abs < 30000.0) { format = new DecimalFormat("#.##"); } else if (abs < 100000.0) { format = new DecimalFormat("#.#"); } else { format = new DecimalFormat("#"); } return format.format(number); } }