Java Lambda - check if an ArrayList to Stream is empty

Stream.findFirst returns an Optional, its up to you to check if the optional has a value rather than just calling get.

You could use the orElse method to return a default value if the optional is empty.


You should probably add what is the type of bonusScheduleDurationContainers. Also it is due to the findFirst().get Function. See the documentation. It states that there will be a exception. You should use orElse