sum all array values java code example
Example 1: sum of arraylist java 8
int total = numbers.stream().mapToInt(i -> i.intValue()).sum();
System.out.print(total);
Example 2: sum of list java
double sum = 0;
for(int i = 0; i < m.size(); i++)
sum += m.get(i);
return sum;