Answers for "how to find the sum of all elements in an array in java using loop"

10

sum of all numbers in array java

int[] a = {10,20,30,40,50};
int sum = IntStream.of(a).sum();
System.out.println("The sum is " + sum);
Posted by: Guest on December-11-2020
0

how to find the sum of an array in java

int [] arr = {1,2,3,4};
int sum = Arrays.stream(arr).sum(); //prints 10
Posted by: Guest on October-09-2021

Code answers related to "how to find the sum of all elements in an array in java using loop"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language