sum the values ​​from the specific field of the objects in a list

Suppose we have an Obj class

class Obj{

  int field;
}

and that you have a list of instances Objfor example List<Obj> lst.

Now, how can I find in Java8 with streams the sum of the values ​​of the int fields field from the objects in the list lst based on a filter criterion (for example, for an object othe criterion o.field > 10)?

Leave a comment