Skip to content

Instantly share code, notes, and snippets.

@AlanHohn
Created October 3, 2016 14:33
Show Gist options
  • Save AlanHohn/bf9ea24bc1e728c2192a11353d69b5c0 to your computer and use it in GitHub Desktop.
Save AlanHohn/bf9ea24bc1e728c2192a11353d69b5c0 to your computer and use it in GitHub Desktop.
Java stream array sum
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