Java Utils Java Java API
java.util.Objects
public static boolean isNull(Object obj)
Returns true if the provided reference is null otherwise returns false. Useful if used as a java.util.function.Predicate.
true
null
false
package com.logicbig.example.objects;import java.util.Objects;public class IsNullExample { public static void main(String... args) { String str = "testString"; //equivalent to obj == null; boolean b = Objects.isNull(str); System.out.println(b); }}
package com.logicbig.example.objects;import java.util.Arrays;import java.util.List;import java.util.Objects;public class IsNullExample2 { public static void main(String... args) { List<String> list = Arrays.asList("a", "b", null, null); boolean b = list.stream().anyMatch(Objects::isNull); System.out.println(b); }}