sum of list java
int sum = (list.stream(). mapToInt(i -> i.intValue()).sum()
Here is what the above code is Doing:
1. We are creating a list of integers.
2. We are converting the list to a stream.
3. We are mapping each element of the stream to its corresponding int value.
4. We are summing up all the elements of the stream.