Java tutorial
//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(); } } return collection; } }