sum of list java 1

sum of list java

int sum = (
        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.

Similar Posts