Here you can find the source of removeNulls(F collection)
public static final <E, F extends Collection<E>> F removeNulls(F collection)
//package com.java2s; //License from project: LGPL import java.util.Collection; import java.util.Iterator; public class Main { public static final <E, F extends Collection<E>> F removeNulls(F collection) { Iterator<E> iterator = collection.iterator(); while (iterator.hasNext()) { if (iterator.next() == null) { iterator.remove();/*from w w w . java2s. c o m*/ } } return collection; } }