Java Collection to Array toArray(Collection values)

Here you can find the source of toArray(Collection values)

Description

Returns an array representation

License

Open Source License

Parameter

Parameter Description
values a parameter

Declaration

public static double[] toArray(Collection<Double> values) 

Method Source Code


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

import java.util.Collection;

public class Main {
    /**//from  w w  w. j a  v a 2  s  .  c o  m
     * Returns an array representation
     * @param values
     * @return
     */
    public static double[] toArray(Collection<Double> values) {
        double[] result = new double[values.size()];
        int i = 0;
        for (Double value : values) {
            result[i] = value;
            i++;
        }

        return result;
    }
}

Related

  1. toArray(Collection c, T[] arr)
  2. toArray(Collection collection)
  3. toArray(Collection tests)
  4. toArray(Collection list)
  5. toArray(Collection values)
  6. toArray(Collection collection)
  7. toArray(Collection collection)
  8. toArray(Collection collection, Long defaultValue)
  9. toArray(Collection col)