Java List to Int List toIntArray(List list)

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

Description

to Int Array

License

Apache License

Declaration

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

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    public static int[] toIntArray(List<Integer> list) {
        int[] array = new int[list.size()];
        for (int i = 0; i < array.length; i++)
            array[i] = list.get(i);/*  w w  w . j a va2  s.c  om*/
        return array;
    }

    public static <T> T get(List<T> l, int i) {
        return get(l, i, null);
    }

    public static <T> T get(List<T> l, int i, T defValue) {
        if (i < 0)
            i += l.size();
        if (i < 0 || i >= l.size())
            return defValue;
        return l.get(i);
    }

    public static <T> T get(T[] l, int i) {
        return get(l, i, null);
    }

    public static <T> T get(T[] l, int i, T defValue) {
        if (i < 0)
            i += l.length;
        if (i < 0 || i >= l.length)
            return defValue;
        return l[i];
    }

    public static double get(double[] l, int i, double defValue) {
        if (i < 0)
            i += l.length;
        if (i < 0 || i >= l.length)
            return defValue;
        return l[i];
    }
}

Related

  1. toIntArray(List ints)
  2. toIntArray(List bytes)
  3. toIntArray(List a)
  4. toIntArray(List integerList)
  5. toIntArray(List intList)
  6. toIntArray(List list)
  7. toIntArray(List list)
  8. toIntArray(List list)
  9. toIntArray(List list)