Answers for "how to use optional in java 8 if ispresent() returns nothing"

0

java optional to collection

public static <T> List<T> toList(Optional<T> opt) {
    return opt
            .map(Collections::singletonList)
            .orElseGet(Collections::emptyList);
}
Posted by: Guest on May-29-2020
0

java optional to collection

public static <T> List<T> toList(Optional<T> opt) {
    return opt
            .map(Collections::singletonList)
            .orElseGet(Collections::emptyList);
}
Posted by: Guest on May-29-2020

Code answers related to "how to use optional in java 8 if ispresent() returns nothing"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language