Java Integer Create toInts(double[] arr)

Here you can find the source of toInts(double[] arr)

Description

This converts an array of doubles to integers (using type-casts, not rounding).

License

Open Source License

Parameter

Parameter Description
arr the array to be converted

Return

an integer version of the given array

Declaration

public static int[] toInts(double[] arr) 

Method Source Code

//package com.java2s;

public class Main {
    /**// ww  w .  ja  v a  2 s .c o  m
     * This converts an array of doubles to integers (using type-casts, not rounding).
     * @param arr the array to be converted
     * @return an integer version of the given array
     */
    public static int[] toInts(double[] arr) {

        int[] ret = new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            ret[i] = (int) arr[i];
        }
        return ret;
    }
}

Related

  1. toIntRound(double[] a)
  2. toInts(byte[] bytes)
  3. toInts(byte[] readBuffer, int o, int l)
  4. toInts(byte[] src, int srcOffset, int[] dst, int dstOffset, int length)
  5. toInts(byte[] value, int offset, int num)
  6. toInts(int val)
  7. toInts(Integer[] values)
  8. toInts(long[] array)
  9. toInts(String intArray)