Java Collection Convert convertCollectionInArray(Collection coll)

Here you can find the source of convertCollectionInArray(Collection coll)

Description

convert Collection In Array

License

Mozilla Public License

Declaration

static public String[] convertCollectionInArray(Collection coll) 

Method Source Code

//package com.java2s;
/* SpagoBI, the Open Source Business Intelligence suite
    /*from  w ww.ja  va2 s. co m*/
 * Copyright (C) 2012 Engineering Ingegneria Informatica S.p.A. - SpagoBI Competency Center
 * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0, without the "Incompatible With Secondary Licenses" notice. 
 * If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import java.util.Collection;

import java.util.Iterator;

public class Main {
    static public String[] convertCollectionInArray(Collection coll) {
        String[] array = new String[coll.size()];
        int i = 0;
        for (Iterator iterator = coll.iterator(); iterator.hasNext();) {
            Object object = (Object) iterator.next();
            String role = object.toString();
            array[i] = role;
            i++;
        }
        return array;
    }
}

Related

  1. convert(Collection list)
  2. convert(Collection c)
  3. convert2IntegerCollection(String[] strs)
  4. convertArrayInCollection(String[] array)
  5. convertCharCollectionToArray(Collection chars)
  6. convertCollectionStringToCSV(Collection coll, boolean valueInSingleQuotes)
  7. convertCollectionType(Iterable from, C newCollection, Class listClass)
  8. convertToCollection(Object source)
  9. convertToHqlParameters(Collection numbers)