Here you can find the source of getArrayFromCollection( Collection
public static <E> String[] getArrayFromCollection( Collection<E> collection)
//package com.java2s; /************************************************************************************ * Copyright (c) 2011 CIMPoint. All rights reserved. * This source is subjected to CIMPoint license as described in the License.txt file. * //from w w w.ja v a 2 s . co m * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. * * Contributors: * pitor - initial implementation ***********************************************************************************/ import java.util.Collection; public class Main { public static <E> String[] getArrayFromCollection( Collection<E> collection) { int size = collection.size(); Object[] objs = collection.toArray(); String[] result = new String[size]; for (int i = 0; i < size; i++) { result[i] = objs[i].toString(); } return result; } }