Java BigDecimal Add sum(List numbers)

Here you can find the source of sum(List numbers)

Description

Returns the sum number in the numbers list.

License

Open Source License

Parameter

Parameter Description
numbers the numbers to calculate the sum.

Return

the sum of the numbers.

Declaration

public static BigDecimal sum(List<BigDecimal> numbers) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.math.BigDecimal;

import java.util.List;

public class Main {
    /**/*from w w  w  . j  ava 2  s  .co  m*/
    * Returns the sum number in the numbers list.
    *
    * @param numbers the numbers to calculate the sum.
    * @return the sum of the numbers.
    */
    public static BigDecimal sum(List<BigDecimal> numbers) {
        BigDecimal sum = new BigDecimal(0);
        for (BigDecimal bigDecimal : numbers) {
            sum = sum.add(bigDecimal);
        }
        return sum;
    }
}

Related

  1. addVAT(int priceInCents, BigDecimal vat)
  2. addVatAmount(BigDecimal percentage, BigDecimal amount)
  3. sum(BigDecimal num1, BigDecimal num2, int scale)
  4. sum(BigDecimal[] bigDecimalNumbers)
  5. sum(final List list)
  6. sumBig(final Collection values)
  7. sumBigDecimal(List vector)
  8. sumCurrencyMap(Map> destMap, Map> mapToSum)