Here you can find the source of toFloatArray(final double[] doubles)
Parameter | Description |
---|---|
doubles | a parameter |
public static float[] toFloatArray(final double[] doubles)
//package com.java2s; /******************************************************************************* * Manchester Centre for Integrative Systems Biology * University of Manchester/*ww w .j a v a2 s.c om*/ * Manchester M1 7ND * United Kingdom * * Copyright (C) 2007 University of Manchester * * This program is released under the Academic Free License ("AFL") v3.0. * (http://www.opensource.org/licenses/academic.php) *******************************************************************************/ import java.util.*; public class Main { /** * * @param doubles * @return float[] */ public static float[] toFloatArray(final double[] doubles) { final float[] floats = new float[doubles.length]; for (int i = 0; i < doubles.length; i++) { floats[i] = (float) doubles[i]; } return floats; } /** * * @param collection * @return float[] */ public static float[] toFloatArray(final Collection<Float> collection) { final float[] array = new float[collection == null ? 0 : collection.size()]; if (collection != null) { int i = 0; for (Iterator<Float> iterator = collection.iterator(); iterator.hasNext();) { array[i++] = iterator.next().floatValue(); } } return array; } }