Java List to Int List toIntArray(List list)

Here you can find the source of toIntArray(List list)

Description

Converts a List of Integer to an int[]

License

Open Source License

Parameter

Parameter Description
list a parameter

Return

an array of int

Declaration

public final static int[] toIntArray(List<Integer> list) 

Method Source Code


//package com.java2s;

import java.util.*;

public class Main {
    /**//from w w  w  .j  a  v  a2s  . com
     * Converts a List of Integer to an int[] 
     * @param list
     * @return an array of int
     */
    public final static int[] toIntArray(List<Integer> list) {
        int[] res = new int[list.size()];
        int index = 0;
        Iterator iter = list.iterator();
        while (iter.hasNext()) {
            Integer i = (Integer) iter.next();
            res[index++] = i.intValue();
        }
        return res;
    }
}

Related

  1. toIntArray(List list)
  2. toIntArray(List list)
  3. toIntArray(List list)
  4. toIntArray(List list)
  5. toIntArray(List list)
  6. toIntArray(List values)
  7. toIntArray_impl(List i_list, int i_offset, int i_size)
  8. toIntegerArray(final List list)
  9. toIntegerArray(List arrayValues)