Here you can find the source of addArrayToCollection(T[] array, Collection
public static <T> void addArrayToCollection(T[] array, Collection<T> collection)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { public static <T> void addArrayToCollection(T[] array, Collection<T> collection) { for (int i = 0; i < array.length; i++) { if (array[i] != null) { collection.add(array[i]); }//from w w w . ja v a 2 s . com } } }