Here you can find the source of toArray(Collection
public static String[] toArray(Collection<String> collection)
//package com.java2s; //License from project: Apache License import java.util.Collection; public class Main { public static String[] toArray(Collection<String> collection) { if (collection == null) { throw new IllegalArgumentException("argument must not be null."); }//from w ww .ja v a 2 s . co m return collection.toArray(new String[collection.size()]); } }