I have a list:
List<FaAccount> accounts = someMethod();
this list contains accountid, currency, balance. Now I want to aggregate balance by currency (sum of balance for each currency). I've created new class with currency and balance variables. This, only copies info from FaAccount into FaAccountBalance
List<FaAccountBalance> aggr = new ArrayList<>();
for(FaAccount account : accounts){
FaAccountBalance ag = new FaAccountBalance();
ag.setCurrency(account.getCurrency());
ag.setBalance(account.getBalance());
aggr.add(ag);
}
How can I put there (into aggr List) one more for loop or some other technique, so that to represent sum of balance for each currency?