how to find the sum of a list in java code example
Example 1: inbuild method to sum of an arraylist elements in java
//If you have a List<Integer>
int sum = list.stream().mapToInt(Integer::intValue).sum();
//If it's an int[]
int sum = IntStream.of(a).sum();
Example 2: inbuild method to sum of an arraylist elements in java
doubleList.stream().reduce((a,b)->a+b).get();