Java List from listOf(double... values)

Here you can find the source of listOf(double... values)

Description

Returns a list of the comma-separated input values.

License

Open Source License

Parameter

Parameter Description
values Comma-separated input values

Return

List of values (iteration order equal to insertion order)

Declaration

public static List<Double> listOf(double... values) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2016 Pablo Pavon-Marino.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl.html
 *
 * Contributors:/*from  www .  j a v  a2s. com*/
 *     Pablo Pavon-Marino - Jose-Luis Izquierdo-Zaragoza, up to version 0.3.1
 *     Pablo Pavon-Marino - from version 0.4.0 onwards
 ******************************************************************************/

import java.util.*;

public class Main {
    /**
     * Returns a list of the comma-separated input values.
     *
     * @param values Comma-separated input values
     * @return List of values (iteration order equal to insertion order)
     */
    public static List<Double> listOf(double... values) {
        return toList(values);
    }

    /**
     * Converts from a {@code double} array to a list.
     *
     * @param array Input array
     * @return A list of {@code Double} objects
     */
    public static List<Double> toList(double[] array) {
        List<Double> list = new ArrayList<Double>();
        for (int i = 0; i < array.length; i++)
            list.add(array[i]);

        return list;
    }
}

Related

  1. listOf(A[] objs)
  2. listOf(Class type)
  3. listOf(Collection coll)
  4. listOf(Collection collection, T... elements)
  5. listOf(Collection... elts)
  6. listOf(E... elements)
  7. listOf(E... elements)
  8. listOf(Iterable it)
  9. listOf(String type)