The method isNull is a static method of the Objects class in java that checks whether the input object reference supplied to it is null or not.
null, then the method returns true.non-null, then the method returns false.This method was introduced in Java 8. To use the nonNull method, import the following module:
java.util.Objects
public static boolean isNull(Object obj)
This method takes one parameter, Object obj, an object reference to check against null.
In the code below, a non-null string object is passed to the isNull method, and returns false:
import java.util.Objects;public class Main {public static void main(String[] args) {String s = "hello";System.out.println(Objects.isNull(s));}}
In the code below, null is passed to the isNull method and returns true:
import java.util.Objects;public class Main {public static void main(String[] args) {System.out.println(Objects.isNull(null));}}