Java List from Array asList(long... array)

Here you can find the source of asList(long... array)

Description

as List

License

Open Source License

Declaration

public static List<Long> asList(long... array) 

Method Source Code


//package com.java2s;
import java.util.ArrayList;

import java.util.Collections;
import java.util.List;

public class Main {
    public static List<Long> asList(long... array) {
        if (array == null)
            return Collections.emptyList();
        List<Long> ret = new ArrayList<Long>(array.length);
        for (long element : array) {
            ret.add(element);// w w  w.j  a v  a 2s.  c om
        }
        return ret;
    }

    public static List<Integer> asList(int... array) {
        if (array == null)
            return Collections.emptyList();
        List<Integer> ret = new ArrayList<Integer>(array.length);
        for (int element : array) {
            ret.add(element);
        }
        return ret;
    }

    public static List<Character> asList(char... array) {
        if (array == null)
            return Collections.emptyList();
        List<Character> ret = new ArrayList<Character>(array.length);
        for (char element : array) {
            ret.add(element);
        }
        return ret;
    }

    public static List<Short> asList(short... array) {
        if (array == null)
            return Collections.emptyList();
        List<Short> ret = new ArrayList<Short>(array.length);
        for (short element : array) {
            ret.add(element);
        }
        return ret;
    }

    public static List<Byte> asList(byte... array) {
        if (array == null)
            return Collections.emptyList();
        List<Byte> ret = new ArrayList<Byte>(array.length);
        for (byte element : array) {
            ret.add(element);
        }
        return ret;
    }

    public static List<Boolean> asList(boolean... array) {
        if (array == null)
            return Collections.emptyList();
        List<Boolean> ret = new ArrayList<Boolean>(array.length);
        for (boolean element : array) {
            ret.add(element);
        }
        return ret;
    }

    public static List<Double> asList(double... array) {
        if (array == null)
            return Collections.emptyList();
        List<Double> ret = new ArrayList<Double>(array.length);
        for (double element : array) {
            ret.add(element);
        }
        return ret;
    }

    public static List<Float> asList(float... array) {
        if (array == null)
            return Collections.emptyList();
        List<Float> ret = new ArrayList<Float>(array.length);
        for (float element : array) {
            ret.add(element);
        }
        return ret;
    }
}

Related

  1. asList(Iterable iterable)
  2. asList(Iterable iterable)
  3. asList(Iterable iterable)
  4. asList(Iterator iterator)
  5. asList(List list)
  6. asList(Object info)
  7. asList(Object o, Class cls)
  8. asList(Object theone)
  9. asList(Object value)