Java Integer Create toIntegerArray(double[] doubles)

Here you can find the source of toIntegerArray(double[] doubles)

Description

Converts an array of double values into an array of integer values by casting them.

License

Open Source License

Parameter

Parameter Description
doubles an array of doubles to convert

Return

a new array of integer values, which is created by casting the double values

Declaration

public static int[] toIntegerArray(double[] doubles) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2011, 2012 itemis AG and others.
 * //from w w  w  . j a va 2 s  .  co m
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Alexander Ny?en (itemis AG) - initial API and implementation
 *     Matthias Wienand (itemis AG) - contribution for Bugzilla #355997
 *     
 *******************************************************************************/

public class Main {
    /**
     * Converts an array of double values into an array of integer values by
     * casting them.
     * 
     * @param doubles
     *            an array of doubles to convert
     * @return a new array of integer values, which is created by casting the
     *         double values
     */
    public static int[] toIntegerArray(double[] doubles) {
        int[] ints = new int[doubles.length];
        for (int i = 0; i < doubles.length; i++) {
            ints[i] = (int) doubles[i];
        }
        return ints;
    }
}

Related

  1. toInteger(String value, Integer defValue)
  2. toInteger(String[] s)
  3. toInteger(String[] source)
  4. toInteger(StringBuilder value)
  5. toIntegerArray(byte[] input, int offset, int len)
  6. toIntegerArray(final int[] array)
  7. toIntegerArray(final int[] ints)
  8. toIntegerArray(String text, String delimiter)
  9. toIntegerArray(String... values)