Here you can find the source of toPrimitiveIntegerArray(Collection
public static int[] toPrimitiveIntegerArray(Collection<Integer> collection)
//package com.java2s; /*// w w w .j a v a 2 s .c o m * Copyright (c) 2012, 2013 Mateusz Parzonka * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Mateusz Parzonka - initial API and implementation */ import java.util.Collection; public class Main { public static int[] toPrimitiveIntegerArray(Collection<Integer> collection) { int[] result = new int[collection.size()]; int i = 0; for (Integer n : collection) { result[i++] = n; } return result; } }