HOW TO CONVERT AN INTEGER ARRAY (INT[]) INTO AN INTEGER LIST (LIST<INTEGER>) IN JAVA?

Andrew Deniel

Total Post:29

Points:203
Posted by  Andrew Deniel
Java 
 1461  View(s)
Ratings:
Rate this:

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

  1. Garry Winogrand

    Post:24

    Points:168
    Re: How to convert an Integer array (int[]) into an Integer List (List<Integer>) in Java?

        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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!