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

Total Post:29

Points:203

Java 
 2137  View(s)
Ratings:
Rate this:

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

  1. 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

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.