Suppose to have a class Obj
:
class Obj {
int field;
}
...and that you have a list of Obj
instances, i.e. List<Obj> lst
.
Now, how can I find with streams the sum of the values of the int fields field
from the objects in list lst
under a filtering criterion (e.g. for an object o
, the criterion is o.field > 10
)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…