Here you can find the source of toIntegerArray(double[] doubles)
Parameter | Description |
---|---|
doubles | an array of doubles to convert |
public static int[] toIntegerArray(double[] doubles)
//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; } }