Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

check if optional is empty java

@Test
public void givenNull_whenCreatesNullable_thenCorrect() {
    String name = null;
    Optional<String> opt = Optional.ofNullable(name);
    assertFalse(opt.isPresent());
}
Source by www.baeldung.com #
 
PREVIOUS NEXT
Tagged: #check #optional #empty #java
ADD COMMENT
Topic
Name
3+1 =