Created
October 3, 2016 14:33
-
-
Save AlanHohn/bf9ea24bc1e728c2192a11353d69b5c0 to your computer and use it in GitHub Desktop.
Java stream array sum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
public class Test { | |
public static void main(String[] args) { | |
int[] arr = { 1, 2, 3, 4, 5 }; | |
int sum = Arrays.stream(arr).sum(); | |
System.out.println("Sum is: " + sum); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment