Java Collection Null removeNulls(F collection)

Here you can find the source of removeNulls(F collection)

Description

remove Nulls

License

LGPL

Declaration

public static final <E, F extends Collection<E>> F removeNulls(F collection) 

Method Source Code

//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();/*from  w  w  w . java2s. c  o m*/
            }
        }

        return collection;
    }
}

Related

  1. removeAllIfNotNull(final Collection collection, final Collection c)
  2. removeNull(Collection collection)
  3. removeNull(final Collection c)
  4. removeNullElement(Collection collection)
  5. removeNulls(Collection p_collection)
  6. removeNulls(final Collection collection)
  7. sortNumbers( Collection values, boolean removeNull)
  8. stripNulls(T collection)
  9. trimToNull(T collection)