Java List Contain containsNullElement(List source)

Here you can find the source of containsNullElement(List source)

Description

Checks whether 'list' has any null element in it.

License

Apache License

Parameter

Parameter Description
source a parameter

Return

boolean

Declaration

public static boolean containsNullElement(List source) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    /**/*from ww  w  .java2s.co  m*/
     * Checks whether 'list' has any null element in it. 1- if list itself is
     * null, return false 2- if list is empty, return false 3- if list contains
     * any null element, return true Note: Return true on first instance of
     * finding null element
     * 
     * @param source
     * @return boolean
     */
    public static boolean containsNullElement(List source) {
        if (source == null)
            return false;
        if (source.isEmpty())
            return false;
        if (source.contains(null))
            return true;
        return false;
    }
}

Related

  1. containsInstance(final List list, final Class clazz)
  2. containsInstance(List list, Object object)
  3. containsItems(List smallerList, List largerList)
  4. containsNonPositives(List vals)
  5. containsNull(List list)
  6. containsOneEqualElem(List first, List second)
  7. containsOnly(List elements, Class clazz)
  8. containsOnlyEmptyValues(List list)
  9. containsOnlyNulls(List list)