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
Post a Comment