Java Collection Element Get getArrayFromCollection( Collection collection)

Here you can find the source of getArrayFromCollection( Collection collection)

Description

get Array From Collection

License

Open Source License

Declaration

public static <E> String[] getArrayFromCollection(
            Collection<E> collection) 

Method Source Code

//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;
    }
}

Related

  1. getAnElement(Collection coll)
  2. getAny(final Collection collection)
  3. getAnyFrom(Collection collection)
  4. getArbitraryMember(Collection s)
  5. getArray(Collection dnaCol)
  6. GetArrayFromCollection(java.util.Collection col)
  7. getArrays(Object parent, Collection collection)
  8. getAssociationCollectionObjectName(Collection currentObjectColl, Collection prevObjectColl)
  9. getAsString(Collection data, char seperator)