Android Collection to Array Convert toPrimitiveLongArray(Collection collection)

Here you can find the source of toPrimitiveLongArray(Collection collection)

Description

to Primitive Long Array

Declaration

public static long[] toPrimitiveLongArray(Collection<Long> collection) 

Method Source Code

//package com.java2s;
import java.util.Collection;

public class Main {
    public static long[] toPrimitiveLongArray(Collection<Long> collection) {
        // Need to do this manually because we're converting to a primitive long array, not
        // a Long array.
        final int size = collection.size();
        final long[] ret = new long[size];
        // Collection doesn't have get(i).  (Iterable doesn't have size())
        int i = 0;
        for (Long value : collection) {
            ret[i++] = value;/*from  ww w  .ja  va 2s.  c om*/
        }
        return ret;
    }
}

Related

  1. toArray(Collection collection)