Answers for "create method with optional parameters java"

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 "create method with optional parameters java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language