Java List to Array toArray(final List list)

Here you can find the source of toArray(final List list)

Description

to Array

License

Open Source License

Parameter

Parameter Description
list a parameter

Return

an array of double values from the given list in the original order;

Declaration

public static double[] toArray(final List<Double> list) 

Method Source Code

//package com.java2s;
/*//from   w w  w  .ja  va  2  s .  c  o m
 * JCAT - TAC Market Design Competition Platform
 * Copyright (C) 2006-2010 Jinzhong Niu, Kai Cai
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 */

import java.util.List;

public class Main {
    /**
     * 
     * @param list
     * @return an array of double values from the given list in the original
     *         order;
     */
    public static double[] toArray(final List<Double> list) {
        final double array[] = new double[list.size()];
        for (int i = 0; i < array.length; i++) {
            array[i] = list.get(i).doubleValue();
        }

        return array;
    }
}

Related

  1. listToArray(List list)
  2. listToArray(List stringList)
  3. listToArray(List list)
  4. toArray(Collection list)
  5. toArray(Collection list)
  6. toArray(final List list)
  7. toArray(final List list)
  8. toArray(List list)
  9. toArray(List list)