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

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 ?