Check out example codes for "java optional to collection". It will help you in understanding the concepts better.

Code Example 1

public static <T> List<T> toList(Optional<T> opt) {
    return opt
            .map(Collections::singletonList)
            .orElseGet(Collections::emptyList);
}

Learn ReactJs, React Native from akashmittal.com