Objects.nonNull method reference use in stream api

suggest change

In the old-fashioned way, a null check over a collection looks like this:

List<Object> someObjects = methodGetList();
for (Object obj : someObjects) {
    if (obj == null) {
        continue;
    }
    doSomething(obj);
}

With the Objects.nonNull method and the Java 8 Stream API, the same check looks like this:

List<Object> someObjects = methodGetList();
someObjects.stream()
           .filter(Objects::nonNull)
           .forEach(this::doSomething);

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents