Java List to Double Array toDoubleArray(final List numbers)

Here you can find the source of toDoubleArray(final List numbers)

Description

to Double Array

License

Apache License

Declaration

static double[] toDoubleArray(final List<? extends Number> numbers) 

Method Source Code

//package com.java2s;
/*//from   w  w w  . ja v  a2  s . c o  m
 * Copyright 2004-2005 Revolution Systems Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.List;

public class Main {
    static double[] toDoubleArray(final List<? extends Number> numbers) {
        final double[] doubles = new double[numbers.size()];
        for (int i = 0; i < doubles.length; i++) {
            final Number number = numbers.get(i);
            doubles[i] = number.doubleValue();
        }
        return doubles;
    }

    static double[] toDoubleArray(final String... values) {
        final double[] doubles = new double[values.length];
        for (int i = 0; i < doubles.length; i++) {
            doubles[i] = Double.valueOf(values[i]);
        }
        return doubles;
    }
}

Related

  1. toDoubleArray(final List list)
  2. toDoubleArray(List a)
  3. toDoubleArray(List list)
  4. toDoubleArray(List list)