Here you can find the source of toStringArray(Collection collection)
Parameter | Description |
---|---|
collection | the Collection to copy |
null
if the passed-in Collection was null
)
@SuppressWarnings({ "unchecked" }) public static String[] toStringArray(Collection collection)
//package com.java2s; /**/*from w w w. j a va2 s .com*/ * <p> * Simple utility class for String operations useful across the framework. * <p/> * <p> * Some methods in this class were copied from the Spring Framework so we didn't * have to re-invent the wheel, and in these cases, we have retained all * license, copyright and author information. * * @since 0.9 */ import java.util.*; public class Main { /** * Copy the given Collection into a String array. The Collection must * contain String elements only. * <p/> * <p> * Copied from the Spring Framework while retaining all license, copyright * and author information. * * @param collection the Collection to copy * @return the String array (<code>null</code> if the passed-in Collection * was <code>null</code>) */ @SuppressWarnings({ "unchecked" }) public static String[] toStringArray(Collection collection) { if (collection == null) { return null; } return (String[]) collection.toArray(new String[collection.size()]); } }