Answers for "sum of array in java using function"

2

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
-1

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 "sum of array in java using function"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language