Here you can find the source of asArray(Collection
public static int[] asArray(Collection<Integer> list)
//package com.java2s; /*/*w w w.ja v a2 s .c o m*/ * Carrot2 project. * * Copyright (C) 2002-2016, Dawid Weiss, Stanis?aw Osi?ski. * All rights reserved. * * Refer to the full license file "carrot2.LICENSE" * in the root folder of the repository checkout or at: * http://www.carrot2.org/carrot2.LICENSE */ import java.util.*; public class Main { public static int[] asArray(Collection<Integer> list) { final int[] result = new int[list.size()]; int index = 0; for (Integer integer : list) { result[index++] = integer; } return result; } }