Convert int Array To List of Integer - Java java.util

Java examples for java.util:List Convert

Description

Convert int Array To List of Integer

Demo Code


//package com.java2s;
import java.util.ArrayList;

import java.util.List;

public class Main {
    public static void main(String[] argv) {
        int[] a = new int[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };
        System.out.println(intArrayToList(a));
    }/*from w  w  w. j a  v  a 2  s  . co m*/

    public static List<Integer> intArrayToList(int[] a) {
        List<Integer> l = new ArrayList<Integer>(a.length);
        for (int x : a)
            l.add(x);
        return l;
    }
}

Related Tutorials