Java Double Array Create doubleArray(String data)

Here you can find the source of doubleArray(String data)

Description

double Array

License

Open Source License

Declaration

public static double[] doubleArray(String data) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static double[] doubleArray(String data) {
        if (data == null || data.equals(""))
            return new double[0];
        String[] split = data.split(" ");
        double[] r = new double[split.length];
        for (int i = 0; i < r.length; i++) {
            try {
                r[i] = Double.parseDouble(split[i]);
            } catch (NumberFormatException e) {
                r[i] = 0;//from  ww w.j  a  va 2  s.c  o  m
            }
        }
        return r;
    }

    public static double parseDouble(String s) {
        if (s != null) {
            try {
                return Double.parseDouble(s);
            } catch (NumberFormatException e) {
            } // Do nothing
        }
        return 0;
    }
}

Related

  1. doubleArray(Double... elements)
  2. doubleArray(int... in)
  3. doubleArray2Json(double[] array)
  4. doubleArrayFromString(final String data)
  5. doubleArrayFromString(String record)
  6. doubleArraySize(byte[] array)