Java List to Double Array toDoubleArray(List stringArray)

Here you can find the source of toDoubleArray(List stringArray)

Description

to Double Array

License

Apache License

Declaration

public static double[] toDoubleArray(List<String> stringArray) 

Method Source Code


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

import java.util.List;

public class Main {
    public static double[] toDoubleArray(List<String> stringArray) {
        if (stringArray == null) {
            return null;
        }//from   ww  w  .j  a v a  2 s.c  om
        double[] result = new double[stringArray.size()];
        for (int i = 0; i < stringArray.size(); i++) {
            try {
                if (stringArray.get(i) != null) {
                    result[i] = Double.parseDouble(stringArray.get(i));
                } else {
                    result[i] = 0.0;
                }
            } catch (Exception e) {
                e.printStackTrace();
                result[i] = 0;
            }
        }
        return result;
    }
}

Related

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