Check out example codes for "inbuild method to sum of an arraylist elements in java". It will help you in understanding the concepts better.

Code Example 1

//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();

Code Example 2

doubleList.stream().reduce((a,b)->a+b).get();

Learn ReactJs, React Native from akashmittal.com