Java List to Double Array toDoubleList(double[] array)

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

Description

to Double List

License

Apache License

Declaration

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

Method Source Code


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

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<Double> toDoubleList(double[] array) {

        List<Double> list = new ArrayList<Double>(array.length);

        for (double el : array)
            list.add(el);// w w  w  . java 2 s . co  m

        return list;
    }

    public static double[] add(double[] array, double element) {

        return insert(array, element, array.length);
    }

    public static int[] add(int[] array, int element) {

        int[] newArr = new int[array.length + 1];

        System.arraycopy(array, 0, newArr, 0, array.length);
        newArr[newArr.length - 1] = element;

        return newArr;
    }

    public static double[] insert(double[] array, double element, int position) {

        if (position < 0)
            position = 0;

        if (position >= array.length)
            position = array.length;

        double[] newArray = new double[array.length + 1];

        System.arraycopy(array, 0, newArray, 0, position);
        newArray[position] = element;
        System.arraycopy(array, position, newArray, position + 1, array.length - position);

        return newArray;
    }
}

Related

  1. toDoubleArray(List list)
  2. toDoubleArray(List list)
  3. toDoubleArray(List values)
  4. toDoubleArray(List stringArray)
  5. toDoubleArray(List values)
  6. toDoubleList(double[] array)
  7. toDoubleList(double[] doubleArray)
  8. toDoubleList(Double[] in)
  9. toDoubleList(final E[] array)