Java Collection to Array toIntArray(final Collection values)

Here you can find the source of toIntArray(final Collection values)

Description

Converts a list of Integer objects into an array of primitive ints.

License

Open Source License

Parameter

Parameter Description
values the list of <code>Integer</code>s

Return

an array of ints

Declaration

public static int[] toIntArray(final Collection<Integer> values) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /**/*  ww w .  j  av a  2  s  .c om*/
     * Converts a list of <code>Integer</code> objects into an array of
     * primitive <code>int</code>s.
     *
     * @param values the list of <code>Integer</code>s
     * @return an array of <code>int</code>s
     */
    public static int[] toIntArray(final Collection<Integer> values) {
        final int[] items = new int[values.size()];
        final Iterator<Integer> iterator = values.iterator();
        for (int i = 0; i < items.length; i++) {
            items[i] = iterator.next();
        }
        return items;
    }
}

Related

  1. toIntArray(Collection list)
  2. toIntArray(Collection values)
  3. toIntArray(final Collection c)
  4. toIntArray(final Collection col)
  5. toIntArray(final Collection collection)
  6. toLongArray(Collection collection)
  7. toLongArray(Collection collection)
  8. toStringArray(Collection collection)
  9. toStringArray(Collection collection)