Java List Create asList(int[] array)

Here you can find the source of asList(int[] array)

Description

needed because Arrays.asList() won't to autoboxing, so if you give it a primitive array you get a singleton list back with just that array as an element.

License

Open Source License

Declaration

public static List<Integer> asList(int[] array) 

Method Source Code


//package com.java2s;

import java.util.*;

public class Main {
    /** needed because Arrays.asList() won't to autoboxing,
     * so if you give it a primitive array you get a
     * singleton list back with just that array as an element.
     *//*from  ww  w  . ja v a2  s . c  o  m*/
    public static List<Integer> asList(int[] array) {
        List<Integer> l = new ArrayList<>();
        for (int i : array) {
            l.add(i);
        }
        return l;
    }
}

Related

  1. asList(E... elements)
  2. asList(E[] array)
  3. asList(final int... values)
  4. asList(final Iterator data)
  5. asList(int[] a)
  6. asList(Iterable iteratable)
  7. asList(Object[] array)
  8. asList(Object[] array)
  9. asList(T... a)