Answers for "optional in java"

2

instantiate optinal java 8

Person p = new Person();
Optional<Person> op = Optional.of(p);
Posted by: Guest on May-15-2020
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"

Java Answers by Framework

Browse Popular Code Answers by Language