Java Array to List toList(double[] array)

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

Description

Converts from a double array to a list.

License

Open Source License

Parameter

Parameter Description
array Input array

Return

A list of Double objects

Declaration

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

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   w ww.ja va 2  s .  c o m*/
 *     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 {
    /**
     * 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. toList(boolean[] array)
  2. toList(Boolean[] list)
  3. toList(byte[] array)
  4. toList(byte[] array)
  5. toList(double[] array)
  6. toList(E... e)
  7. toList(E... values)
  8. toList(E[] array, int fromIndex, int toIndex)
  9. toList(final double[] array)