samedi 27 août 2016

Sense of Optional in Java 8

What is a sense of this?

Optional.of(someLinkToNull).ifPresent(present -> {
        System.out.println(present);
    });

gives NullpointerException.

Please, give an example, how to check on null with Optional (less code)?

Aucun commentaire:

Enregistrer un commentaire