Convert Integer List To int Array - Java java.util

Java examples for java.util:List Convert

Description

Convert Integer List To int Array

Demo Code


//package com.java2s;

import java.util.List;

public class Main {
    public static void main(String[] argv) {
        List l = java.util.Arrays.asList("asdf", "java2s.com");
        System.out.println(java.util.Arrays.toString(intListToArray(l)));
    }//from   ww  w  .j  a v  a2  s.  co m

    public static int[] intListToArray(List<Integer> l) {
        int[] a = new int[l.size()];
        for (int i = 0; i < a.length; i++) {
            a[i] = l.get(i);
        }
        return a;
    }
}

Related Tutorials