Answers for "how to make a opinal variable in a void method"

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
0

java how to make a parameter optional

void foo(String a, Integer b, Integer c) {
    b = b != null ? b : 0;
    c = c != null ? c : 0;
    //...
}

foo("a", null, 2);
Posted by: Guest on July-16-2020

Code answers related to "how to make a opinal variable in a void method"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language