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

What are POJO classes in spring? What is the use of POJO Class, and How to create POJO classes.

How to create React project using command prompt?