Java Collection Copy copyWithoutNull(Collection orig)

Here you can find the source of copyWithoutNull(Collection orig)

Description

copy Without Null

License

Open Source License

Declaration

public static <E> ArrayList<E> copyWithoutNull(Collection<E> orig) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;
import java.util.Collection;

public class Main {
    public static <E> ArrayList<E> copyWithoutNull(Collection<E> orig) {
        ArrayList<E> ret = new ArrayList<E>();
        if (orig == null)
            return ret;
        for (E e : orig) {
            if (e != null)
                ret.add(e);/*from   ww w  . j av  a  2s  .  c  o  m*/
        }
        return ret;
    }
}

Related

  1. copyColl(Collection out, Iterable set)
  2. copyIntoCollectionFrom(Collection collection, Iterable iterable)
  3. copyNSorted(final Collection source, final Collection dest, final Comparator order, final int n)
  4. copyRemainder(final T[] sourceArray, final int startIndex, final Collection collector)
  5. copyStringCollection(Collection strings)
  6. createSet(Collection toCopy)
  7. maskedCopyOf(final Collection source, final Collection mask)
  8. shallowCopy(Collection collection)
  9. toUnmodifiableCopy(Collection collection)