SyntaxFix
Write A Post
Hire A Developer
Questions
In Java 8 for an Obj entity with field and getField() method you can use:
Obj
field
List<Obj> objs ... Stream<Obj> notNullObjs = objs.stream().filter(obj -> obj.getValue() != null); Double sum = notNullObjs.mapToDouble(Obj::getField).sum();