How to find Sum Of Integers

 Interview Question for 2+ experienced

How to find Sum Of Integers

Solution :

package p2;
import java.util.List;
import java.util.Arrays;
public class SumOfInteger {
public static void main(String[] args) {
List<Integer> list=Arrays.asList(10,30,20);
    Integer sum=list.stream().mapToInt(i->i).sum();
    System.out.println(sum);
}
}

******************************************************************

O/P : 60


Comments

Popular posts from this blog

How to create React project using command prompt?

How to achieve abstraction?

Interview Question? How to find square of each element in this Array {2,4,5,6,8} using map ?