Java List Contain containsNull(List list)

Here you can find the source of containsNull(List list)

Description

Returns true if the given (non-null) List contains null as one of its values.

License

Open Source License

Parameter

Parameter Description
list The list to be checked to see if it contains null

Return

true if the given List contains null as one of its values; false otherwise

Declaration

public static boolean containsNull(List<?> list) 

Method Source Code


//package com.java2s;
/*//from w ww .j a  va 2 s.c  o  m
 * Copyright 2017 (C) Tom Parker <thpr@users.sourceforge.net>
 *
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GNU Lesser General Public License as published by the Free Software Foundation;
 * either version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with
 * this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 * Suite 330, Boston, MA 02111-1307 USA
 */

import java.util.List;

public class Main {
    /**
     * Returns true if the given (non-null) List contains null as one of its values.
     * 
     * @param list
     *            The list to be checked to see if it contains null
     * @return true if the given List contains null as one of its values; false otherwise
     */
    public static boolean containsNull(List<?> list) {
        for (Object o : list) {
            if (o == null) {
                return true;
            }
        }
        return false;
    }
}

Related

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