Java Double Array to Int Array doublesToInts(final double[] array)

Here you can find the source of doublesToInts(final double[] array)

Description

convert an array of double values to an array of int .

License

Open Source License

Parameter

Parameter Description
array the array of double

Return

the array of int

Declaration

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

Method Source Code

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

public class Main {
    /**/*from w  w w  .j  av a 2  s.c om*/
     * convert an array of {@code double} values to an array of {@code int}.
     *
     * @param array
     *          the array of {@code double}
     * @return the array of {@code int}
     */
    public static final int[] doublesToInts(final double[] array) {
        final int[] res;
        int i;

        res = new int[array.length];
        i = 0;
        for (final double x : array) {
            res[i++] = ((int) x);
        }

        return res;
    }
}

Related

  1. arrayDoubleToArrayInt(final double[] array)