Java List Sum sum_ints(List list)

Here you can find the source of sum_ints(List list)

Description

suints

License

Open Source License

Declaration

public static int sum_ints(List<Integer> list) 

Method Source Code

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

import java.util.*;

public class Main {
    public static int sum_ints(List<Integer> list) {
        if (list == null || list.size() < 1)
            return 0; // shouldn't this throw a null pointer exception? otherwise how do we differentiate null from a list of zeroes?

        int sum = 0;
        for (Integer i : list)
            sum = sum + i;//from w  w w. j  av a 2s  . co  m

        return sum;
    }
}

Related

  1. sum(List list)
  2. sum(List lst)
  3. sum(List numbers)
  4. sum(List numbers)
  5. sum(List listOfNumbers)
  6. sumAll(List list)
  7. sumAllColumnsOfMatrix(List> matrix)
  8. sumCreditList(List list)
  9. sumDifferences(List a, List b)