I have a List<BigInteger>
and I want to sum its contents. It can be easily done by looping through it.
List<BigInteger> listOfNumbers = new ArrayList<>();
//Some code that populates listOfNumbers
...
BigInteger sum = new BigInteger("0");
for(BigInteger num : listOfNumbers) {
sum = sum.add(num);
}
I was wondering if it was possible to do it using Java 8
streams.