How to find sum of Integer using For Loop?

 Q. How to find sum of Integer using For Loop?

SOLUTION:-


package v1;

import java.util.*;

import java.util.Arrays;


public class SumOfIntegerUsingForLoop {


public static void main(String[] args) {

List<Integer> list=Arrays.asList(10,20,30,40);

Integer sum=0;

for(Integer a:list) {

sum=sum+a;

}

        System.out.println("Sum Of Integer:"+sum);

}


}


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



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?