user91638
0
Q:

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();
0
doubleList.stream().reduce((a,b)->a+b).get();
0

New to Communities?

Join the community