Java Collection to Array toIntArray(Collection coll)

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

Description

to Int Array

License

LGPL

Declaration

public static int[] toIntArray(Collection coll) 

Method Source Code

//package com.java2s;
/*/*from   www  . j  a v a 2  s.  com*/
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
 */

import java.util.Collection;
import java.util.Iterator;

public class Main {
    public static int[] toIntArray(Collection coll) {
        Iterator iter = coll.iterator();
        int[] arr = new int[coll.size()];
        int i = 0;
        while (iter.hasNext()) {
            arr[i++] = (Integer) iter.next();
        }
        return arr;
    }
}

Related

  1. toDoubleArray(final Collection doubleColl)
  2. toFloatArray(Collection collection)
  3. toFloatArray(Collection c)
  4. toFloatArray(Collection array)
  5. toFloatArray(final Collection c)
  6. toIntArray(Collection coll)
  7. toIntArray(Collection collection)
  8. toIntArray(Collection collection)
  9. toIntArray(Collection collection)