Java Collection to Array toFloatArray(Collection array)

Here you can find the source of toFloatArray(Collection array)

Description

to Float Array

License

Open Source License

Declaration

public static float[] toFloatArray(Collection<Float> array) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;

public class Main {
    public static float[] toFloatArray(Collection<Float> array) {
        float[] resultArray = new float[array.size()];
        int i = 0;
        for (float s : array) {
            resultArray[i++] = s;/*from   www.ja va2 s.  c o  m*/
        }
        return resultArray;
    }

    public static float[][] toFloatArray(Collection<Float>[] array) {
        float[][] resultArray = new float[array.length][];
        int i = 0;
        for (int j = 0; j < array.length; j++) {
            resultArray[j] = new float[array[j].size()];
            for (float s : array[j]) {
                resultArray[j][i++] = s;
            }
        }
        return resultArray;
    }
}

Related

  1. toDoubleArray(Collection items)
  2. toDoubleArray(Collection ds)
  3. toDoubleArray(final Collection doubleColl)
  4. toFloatArray(Collection collection)
  5. toFloatArray(Collection c)
  6. toFloatArray(final Collection c)
  7. toIntArray(Collection coll)
  8. toIntArray(Collection coll)
  9. toIntArray(Collection collection)