Here you can find the source of toCommaSeparatedString(Iterator i)
public static String toCommaSeparatedString(Iterator<? extends Object> i)
//package com.java2s; /* released under bsd licence * see LICENCE file or http://www.opensource.org/licenses/bsd-license.php for details * Institute of Applied Simulation (ZHAW) * Author Thomas Niederberger//w w w . j a v a2 s. c om */ import java.util.Iterator; public class Main { public static String toCommaSeparatedString(Iterator<? extends Object> i) { StringBuilder sb = new StringBuilder(); for (; i.hasNext();) { sb.append(i.next().toString()); if (i.hasNext() == true) { sb.append(", "); } } return sb.toString(); } public static String toCommaSeparatedString(double[] list) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < list.length; i++) { sb.append(Double.toString(list[i])); if ((i + 1) < list.length) { sb.append(", "); } } return sb.toString(); } }