Here you can find the source of toArrayString(Collection> col, boolean spacing)
public static String[] toArrayString(Collection<?> col, boolean spacing)
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.Iterator; public class Main { public static String[] toArrayString(Collection<?> col, boolean spacing) { int size = col.size(); if (spacing) { size++;// w ww . jav a 2 s .co m } String[] result = new String[size]; int i = 0; if (spacing) { result[i++] = ""; } Iterator<?> it = col.iterator(); while (it.hasNext()) { result[i++] = it.next().toString(); } return result; } }