I have class say for example public class Item {
int price;
String name;
// getters and setters
}
I have such 1000 or more objects (just example).
For each item there is a different price. And All this item objects are in List<Item>
my requirement is to get total price (i.e price for item 1 to nth item of the list).
Is there any utility or way by which i can get total for the particular field (i.e total price of all the items). I just give List, ClassName and fieldName I get the total? I know we can get the total by iterating through the list, call get method add all up and store in some variable.?
Thanks in advance.