Avishay28
0
Q:

check if optional is empty java

@Test
public void givenNull_whenCreatesNullable_thenCorrect() {
    String name = null;
    Optional<String> opt = Optional.ofNullable(name);
    assertFalse(opt.isPresent());
}
1
String o = getOptional().orElse(null);
if (o == null) {
    return;
}
0

New to Communities?

Join the community