Here you can find the source of toIntArray(final Collection
Integer
objects into an array of primitive int
s.
Parameter | Description |
---|---|
values | the list of <code>Integer</code>s |
int
s
public static int[] toIntArray(final Collection<Integer> values)
//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; } }