Here you can find the source of removeNullElement(Collection
public static <T> Collection<T> removeNullElement(Collection<T> collection)
//package com.java2s; /*L//from w w w. j a v a 2s. co m * Copyright SAIC, Ellumen and RSNA (CTP) * * * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/national-biomedical-image-archive/LICENSE.txt for details. */ import java.util.ArrayList; import java.util.Collection; public class Main { public static <T> Collection<T> removeNullElement(Collection<T> collection) { Collection<T> result = new ArrayList<T>(); for (T t : collection) { if (t != null) { result.add(t); } } return result; } }