Java List Value Add All addArrayToList(List list, double[] array)

Here you can find the source of addArrayToList(List list, double[] array)

Description

Add the contents of the array to the list

License

Apache License

Parameter

Parameter Description
list a parameter
array a parameter

Return

A copy of the original list, with the array values added to it.

Declaration

public static List<Double> addArrayToList(List<Double> list, double[] array) 

Method Source Code

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

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**/*  w  ww  .  j a  v  a  2  s  .  c o m*/
     * Add the contents of the array to the list
     *
     * @param list
     * @param array
     * @return A copy of the original list, with the array values added to it.
     */
    public static List<Double> addArrayToList(List<Double> list, double[] array) {
        List<Double> copiedList = new ArrayList<>(list);
        //if parameter is constrained there is a null instead of an array
        if (array == null) {
            copiedList.add(null);
            copiedList.add(null);
        } else {
            for (int i = 0; i < array.length; i++) {
                copiedList.add(array[i]);
            }
        }
        return copiedList;
    }
}

Related

  1. addAllUnique(List l1, T element)
  2. addAllUniqueId(List aList, List theObjects)
  3. addAllUniqueToList(List objects, List objectsToAdd)
  4. addAllWords(String text, List result)
  5. addArrayToList(List list, String as[])
  6. addArrayToList(List list, T[] array)
  7. addArrayToList(String[] array, List list)
  8. addArrayToList(T[] array, List list)
  9. addToList(List list, Object obj)