Home > DeveloperSection > Forums > How to convert an Integer array (int[]) into an Integer List (List<Integer>) in Java?
Andrew Deniel
Andrew Deniel

Total Post:29

Points:203
Posted on    October-05-2013 3:59 AM

 Java Java 
Ratings:


 1 Reply(s)
 1068  View(s)
Rate this:

How do I convert int[] into List<Integer> in Java?



Garry Winogrand
Garry Winogrand

Total Post:24

Points:168
Posted on    October-05-2013 4:26 AM

    int[] ints = {1, 2, 3};
    List<Integer> intList = new ArrayList<Integer>();
    for (int index = 0; index < ints.length; index++)
    {
        intList.add(ints[index]);
    }

Note: - You can use a trick to convert an Integer array to an Integer List.


Don't want to miss updates? Please click the below button!

Follow MindStick