I want to summarize the attributes of my objects. The objects have a structure like this:
class Foo{
String name;
int = price;
int = fees;
//etc
}
I have collected them into a List and want to get (with streams) a list of all elements that only contain the name and the sum of the price and fees. For example:
{name=Apple, price=2; fees=1}
{name=Potato, price=7, fees=10}
{name=strawberry, price=5, fees=4}
should lead to this result:
{name=Apple, sum=3}
{name=Potato, sum=17}
{name=strawberry, sum=9}