Here you can find the source of toLongArray(Collection
Parameter | Description |
---|---|
collection | Collection to be convert. |
public static Long[] toLongArray(Collection<Long> collection)
//package com.java2s; /*L/*w ww .j a v a 2 s .com*/ * Copyright Washington University in St. Louis, SemanticBits, Persistent Systems, Krishagni. * * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/commons-module/LICENSE.txt for details. */ import java.util.Collection; import java.util.Iterator; public class Main { /** * This method converts collection to Long Array. * @param collection Collection to be convert. * @return long array. */ public static Long[] toLongArray(Collection<Long> collection) { Long[] obj = new Long[collection.size()]; int index = 0; Iterator<Long> iterator = collection.iterator(); while (iterator.hasNext()) { obj[index] = (Long) iterator.next(); index++; } return obj; } }