Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.Iterator; import java.util.Map; public class Main { public static void filterNull(Collection<?> collection) { if (!isEmpty(collection)) { for (Iterator<?> it = collection.iterator(); it.hasNext();) { if (it.next() == null) { it.remove(); } } } } public static boolean isEmpty(Collection<?> collection) { return collection == null || collection.isEmpty(); } public static boolean isEmpty(Map<?, ?> map) { return map == null || map.isEmpty(); } }