Java List from Array arrayToList(int[] a)

Here you can find the source of arrayToList(int[] a)

Description

make an Array of the type int[] into ArrayList.

License

Open Source License

Declaration

public static ArrayList<Integer> arrayToList(int[] a) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

public class Main {
    /**//from w w w . j  a v  a 2  s  .  c o  m
     * make an Array of the type int[] into ArrayList<Integer>. We need this
     * because there is no autoboxing between Integer and int types hence
     * Arrays.aslist cannot be used for this conversion
     */
    public static ArrayList<Integer> arrayToList(int[] a) {
        ArrayList<Integer> ret = new ArrayList<Integer>();
        for (int i = 0; i < a.length; i++) {
            ret.add(a[i]);
        }
        return ret;
    }
}

Related

  1. arrayToList(@SuppressWarnings("unchecked") T... a)
  2. arrayToList(char[] charArr)
  3. arrayToList(Comparable[] array)
  4. arrayToList(E[] array)
  5. arrayToList(final String... array)
  6. arrayToList(int[] array)
  7. arrayToList(int[] array)
  8. arrayToList(Object arr[], int from, int length)
  9. arrayToList(Object data)