Here you can find the source of toStringArray(Collection> collection)
static String[] toStringArray(Collection<?> collection)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { private static final String[] EMPTY_STRING_ARRAY = new String[0]; static String[] toStringArray(Collection<?> collection) { if (collection == null) { return null; }/*from www . ja v a2s .c om*/ if (collection.isEmpty()) { return EMPTY_STRING_ARRAY; } List<String> list = new ArrayList<>(collection.size()); for (Object o : collection) { list.add(o == null ? null : o.toString()); } return list.toArray(new String[list.size()]); } }