Answers for "java optional as a parameter"

0

java how to make a parameter optional

void foo(String a, Optional<Integer> bOpt) {
    Integer b = bOpt.isPresent() ? bOpt.get() : 0;
    //...
}

foo("a", Optional.of(2));
foo("a", Optional.<Integer>absent());
Posted by: Guest on July-16-2020

Code answers related to "java optional as a parameter"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language