Here you can find the source of listToArray(List
Parameter | Description |
---|---|
doubles | a list of Doubles |
public static double[] listToArray(List<Double> doubles)
//package com.java2s; /**// w ww . j a v a 2 s . c om * This file is part of SemEvalCortical. * <p> * Foobar 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 3 of the License, or * (at your option) any later version. * <p> * Foobar 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. * <p> * You should have received a copy of the GNU General Public License * along with SemEvalCortical. If not, see <http://www.gnu.org/licenses/>. */ import java.util.List; public class Main { /** * Convert a list of Doubles to an array of primitive double types. * * @param doubles a list of Doubles * @return an array of doubles of the length of the input list */ public static double[] listToArray(List<Double> doubles) { double[] array = new double[doubles.size()]; for (int i = 0; i < doubles.size(); i++) { array[i] = doubles.get(i); } return array; } }