Here you can find the source of removeNulls(Collection
static public <T> void removeNulls(Collection<T> list)
//package com.java2s; import java.util.Collection; import java.util.Iterator; public class Main { static public <T> void removeNulls(Collection<T> list) { for (Iterator<T> iter = list.iterator(); iter.hasNext();) { T e = iter.next();/*ww w .j a v a 2 s . c o m*/ if (e == null) iter.remove(); } } }