Here you can find the source of copyWithoutNull(Collection
public static <E> ArrayList<E> copyWithoutNull(Collection<E> orig)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collection; public class Main { public static <E> ArrayList<E> copyWithoutNull(Collection<E> orig) { ArrayList<E> ret = new ArrayList<E>(); if (orig == null) return ret; for (E e : orig) { if (e != null) ret.add(e);/*from ww w . j av a 2s . c o m*/ } return ret; } }