Here you can find the source of removeNull(Collection
public static void removeNull(Collection<Object> list)
//package com.java2s; /*/*from w w w.ja va 2s . c o m*/ * Copyright 1998-2012 360buy.com All right reserved. This software is the confidential and proprietary information of * 360buy.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only * in accordance with the terms of the license agreement you entered into with 360buy.com. */ import java.util.Collection; import java.util.Iterator; public class Main { public static void removeNull(Collection<Object> list) { if (list == null || list.size() == 0) { return; } Iterator<Object> iter = list.iterator(); while (iter.hasNext()) { if (iter.next() == null) { iter.remove(); } } } }