I've got a list of BigDecimals to sum. If they were Strings to concatenate, I would use StringBuilder to reduce object creation. Is there something similar for BigDecimal? Or maybe I shouldn't bother about it? Is optimization of BigDecimal creation worth putting effort to it?
BigDecimal result = BigDecimal.ZERO;
for (CashReportElement element : getReportElementSet()) {
if (element.getCurrencyCode().equals(currencyCode)) {
result = result.add(element.getSum());
}
}
return result;