Answers for "check if optional is empty java"

1

check if optional is empty java

@Test
public void givenNull_whenCreatesNullable_thenCorrect() {
    String name = null;
    Optional<String> opt = Optional.ofNullable(name);
    assertFalse(opt.isPresent());
}
Posted by: Guest on February-26-2020
0

check if optional is empty java

String o = getOptional().orElse(null);
if (o == null) {
    return;
}
Posted by: Guest on February-26-2020

Code answers related to "check if optional is empty java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language