Here you can find the source of toPrimitive(final Double[] arr)
Parameter | Description |
---|---|
arr | Double array to convert to double array |
public static double[] toPrimitive(final Double[] arr)
//package com.java2s; /******************************************************************************* * Copyright (c) 2015, 2017 Lablicate GmbH. * * 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:/*from ww w. ja v a 2 s . c o m*/ * Dr. Alexander Kerner - initial API and implementation *******************************************************************************/ public class Main { /** * * Returns a {@code double} array containing the {@code double} representation of given {@link Double} array. * </p> * Note: {@code null values} in {@code arr} are ignored! Length of returned array * may be less than length of input array therefore. * * @param arr * {@link Double} array to convert to {@code double} array * @return a {@code double} array containing the {@code double} representation of given {@link Double} array */ public static double[] toPrimitive(final Double[] arr) { final double[] result = new double[arr.length]; for (int i = 0; i < arr.length; i++) result[i] = arr[i]; return result; } /** * * Returns a {@code int} array containing the {@code int} representation of * given {@link Integer} array. * </p> * Note: {@code null values} in {@code arr} are ignored! Length of returned array may be less than length * of input array therefore. * * @param arr * {@link Integer} array to convert to {@code int} array * @return a {@code int} array containing the {@code int} representation of * given {@link Integer} array */ public static int[] toPrimitive(final Integer[] arr) { final int[] result = new int[arr.length]; for (int i = 0; i < arr.length; i++) if (arr[i] != null) { result[i] = arr[i]; } return result; } /** * * Returns a {@code double} array containing the {@code double} representation of given {@link Number} array. * </p> * Note: {@code null values} in {@code arr} are ignored! Length of returned array * may be less than length of input array therefore. * * @param arr * {@link Number} array to convert to {@code double} array * @return a {@code double} array containing the {@code double} representation of given {@link Number} array */ public static double[] toPrimitive(final Number[] arr) { final double[] result = new double[arr.length]; for (int i = 0; i < arr.length; i++) { if (arr[i] != null) { result[i] = arr[i].doubleValue(); } } return result; } }