Skip to content

Instantly share code, notes, and snippets.

@carlosmaniero
Created March 20, 2017 21:52
Show Gist options
  • Save carlosmaniero/70f0ae0d6604e3d00d0e5888211fae3a to your computer and use it in GitHub Desktop.
Save carlosmaniero/70f0ae0d6604e3d00d0e5888211fae3a to your computer and use it in GitHub Desktop.
import java.util.stream.Stream;
public class ReduceSum {
public static void main(String args[]) {
int sum = Stream.of(1, 2, 3, 4, 5)
.reduce(0, (acc, item) -> acc + item);
System.out.println(sum);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment