Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

get all objects from List and store in Optional

I have an API which returns list of objects, I wanted to get all the objects from list and store in Optional

I have come across findFirst() and findAny() but I am not sure if they can work to store all elements from list to Optional

List<Object> list= outputFromAPI;
Optional<Object> convert = outputFromAPI.stream().findAny();

How can I store all the elements?

Comments