Java Array Create toArrayDouble(final int[] array)

Here you can find the source of toArrayDouble(final int[] array)

Description

Convert an array of int to an array of double

License

GNU General Public License

Parameter

Parameter Description
array Array to convert

Return

a new array of double

Declaration

public static double[] toArrayDouble(final int[] array) 

Method Source Code

//package com.java2s;
/*/*from   w  w  w  . java 2s.  com*/
 *                      Nividic development code
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  If you do not have a copy,
 * see:
 *
 *      http://www.gnu.org/copyleft/lesser.html
 *
 * Copyright for this code is held jointly by the microarray platform
 * of the ?cole Normale Sup?rieure and the individual authors.
 * These should be listed in @author doc comments.
 *
 * For more information on the Nividic project and its aims,
 * or to join the Nividic mailing list, visit the home page
 * at:
 *
 *      http://www.transcriptome.ens.fr/nividic
 *
 */

public class Main {
    /**
     * Convert an array of int to an array of double
     * @param array Array to convert
     * @return a new array of double
     */
    public static double[] toArrayDouble(final int[] array) {

        if (array == null)
            return null;

        final double[] result = new double[array.length];

        for (int i = 0; i < result.length; i++)
            result[i] = array[i];

        return result;
    }

    /**
     * Convert an array of int to an array of double
     * @param array Array to convert
     * @return a new array of double
     */
    public static double[] toArrayDouble(final String[] array) {

        if (array == null)
            return null;

        final double[] result = new double[array.length];

        for (int i = 0; i < result.length; i++)
            if (array[i] != null)
                result[i] = Double.parseDouble(array[i]);

        return result;
    }
}

Related

  1. toArray(String string)
  2. toArray(String text)
  3. toArray(T... items)
  4. toArray(T... items)
  5. toArrayClass(String className)
  6. toArrayElement(String s)
  7. toArrayLE(int val)