Java Collection Add addIfNotNull(Collection c, Object element)

Here you can find the source of addIfNotNull(Collection c, Object element)

Description

add If Not Null

License

Open Source License

Declaration

public static void addIfNotNull(Collection c, Object element) 

Method Source Code


//package com.java2s;

import java.util.Collection;

public class Main {

    public static void addIfNotNull(Collection c, Object element) {
        if (element != null) {
            c.add(element);//  w w  w .  j a  va  2  s  .  c  o  m
        }
    }
}

Related

  1. addIf(Collection coll, T value, boolean expr)
  2. addIfAbsent(Collection c, T item)
  3. addIfMissing(Collection result, Iterable addition)
  4. addIfNotContains(Collection collection, T value)
  5. addIfNotEmpty(Collection c, Collection elements)
  6. addIfNotNull(Collection coll, T value)
  7. addIfNotNull(Collection listToAddTo, T itemToAddToList, Object objectToCheckIfNull)
  8. addIfNotNull(final Collection collection, final V value)
  9. addIgnoreNull(Collection collection, Object object)