Java List to Int List toIntArray(List list)

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

Description

This converts a list to it's primitive state.

License

Open Source License

Parameter

Parameter Description
list The list to convert

Return

The primitive array instance of the list's contents.

Declaration

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

Method Source Code

//package com.java2s;

import java.util.List;

public class Main {
    /**/*  w w  w  .j a v a  2s.com*/
     * This converts a list to it's primitive state.
     * In this case, it converts an {@link Integer} list to a
     * int array.
     * 
     * @param list The list to convert
     * @return The primitive array instance of the list's contents.
     */
    public static int[] toIntArray(List<Integer> list) {
        int[] array = new int[list.size()];
        for (int i = 0; i < list.size(); i++) {
            array[i] = list.get(i);
        }
        return array;
    }

    public static int[] toIntArray(int... arr) {
        return arr;
    }
}

Related

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