Here you can find the source of containsNull(List> list)
Parameter | Description |
---|---|
list | The list to be checked to see if it contains null |
public static boolean containsNull(List<?> list)
//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; } }