Java List from Array arrayToList(int[] array)

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

Description

array To List

License

Apache License

Declaration

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

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;

import java.util.Collection;

import java.util.Map;

public class Main {

    public static ArrayList<Integer> arrayToList(int[] array) {
        if (isEmpty(array)) {
            return null;
        }/*from w  w w .ja v  a  2s .c o m*/
        ArrayList<Integer> result = new ArrayList<Integer>();
        for (int num : array) {
            result.add(num);
        }
        return result;
    }

    public static boolean isEmpty(Collection<?> col) {
        if (col == null || col.size() == 0) {
            return true;
        } else {
            return false;
        }
    }

    public static <T> boolean isEmpty(T[] col) {
        if (col == null || col.length == 0) {
            return true;
        } else {
            return false;
        }
    }

    public static boolean isEmpty(int[] array) {
        if (array == null || array.length == 0) {
            return true;
        }
        return false;
    }

    public static boolean isEmpty(double[] array) {
        if (array == null || array.length == 0) {
            return true;
        }
        return false;
    }

    public static boolean isEmpty(byte[] array) {
        if (array == null || array.length == 0) {
            return true;
        } else {
            return false;
        }
    }

    public static boolean isEmpty(Map<?, ?> map) {
        if (map == null || map.size() == 0) {
            return true;
        } else {
            return false;
        }
    }
}

Related

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