Java tutorial
//package com.java2s; import java.util.*; public class Main { static public <T> void removeNulls(Collection<T> list) { for (Iterator<T> iter = list.iterator(); iter.hasNext();) { T e = iter.next(); if (e == null) iter.remove(); } } }