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);
}
}
Leave a Reply