DEV Community

Discussion on: Streams in Java

Collapse
 
prasadchillara_55 profile image
Prasad Chillara • Edited

Hi Dan,

ifPresent method of reduces/terminal Operators can also be used here.

listOfValues
.stream()
.filter(y -> y.isChildrenOf(account))
.map(TotalSsn::getImporte)
.reduce((a, b) -> (a.add(b)))
.ifPresent(totaloptional -> total = totaloptional);

Thanks
Prasad Chillara

Thread Thread
 
elcotu profile image
Daniel Coturel

Thanks