Java List to Array asArray(Collection list)

Here you can find the source of asArray(Collection list)

Description

as Array

License

Open Source License

Declaration

public static int[] asArray(Collection<Integer> list) 

Method Source Code


//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;
    }
}

Related

  1. asArray(List values)
  2. asArray(List indices)
  3. asArray(List list)
  4. asArray(List list)