Java Utililty Methods Collection Sum

List of utility methods to do Collection Sum

Description

The list of methods to do Collection Sum are organized into topic(s).

Method

intsum(final Collection values)
Sums the values in the collection.
int sum = 0;
for (Integer operand : values) {
    if (Integer.MAX_VALUE - sum < operand) {
        throw new Exception("Overflow.");
    sum += operand;
return sum;
...
DoublesumDouble(Collection collection)
sum Double
Double result = 0.0;
for (Double n : collection) {
    result += n;
return result;
StringsummarizeCollection(Collection collection, String collectionType, String elementType)
summarize Collection
if (collection == null) {
    return "null";
return collectionType + "<" + elementType + ">(size=" + collection.size() + ")";
DoublesumNumberCollection(Collection numbers)
sum Number Collection
double sum = 0.0;
for (T t : numbers) {
    sum += t.doubleValue();
return sum;