Java List from Array asList(double[] array)

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

Description

as List

License

Apache License

Declaration

public static List<Double> asList(double[] array) 

Method Source Code

//package com.java2s;
/*// ww  w.  java2  s  .  c  o m
 * Copyright 2015-16, Yahoo! Inc.
 * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
 */

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<Double> asList(double[] array) {
        List<Double> list = new ArrayList<Double>(array.length);
        for (int i = 0; i < array.length; i++)
            list.add(array[i]);
        return list;
    }

    public static List<Float> asList(float[] array) {
        List<Float> list = new ArrayList<Float>(array.length);
        for (int i = 0; i < array.length; i++)
            list.add(array[i]);
        return list;
    }

    public static List<Long> asList(long[] array) {
        List<Long> list = new ArrayList<Long>(array.length);
        for (int i = 0; i < array.length; i++)
            list.add(array[i]);
        return list;
    }
}

Related

  1. asList(Collection collection, Class type)
  2. asList(Collection values)
  3. asList(Collection c)
  4. asList(Collection coll)
  5. asList(Collection collection)
  6. asList(E... elements)
  7. asList(E... pEntities)
  8. asList(E[] array)
  9. asList(final char[] array)