Skip to content

Instantly share code, notes, and snippets.

@danielkec
Created March 20, 2020 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielkec/bb29f12019c4d5e61f3fea094b38edb1 to your computer and use it in GitHub Desktop.
Save danielkec/bb29f12019c4d5e61f3fea094b38edb1 to your computer and use it in GitHub Desktop.
AtomicInteger sum = new AtomicInteger();
ReactiveStreams.of("1", "2", "3", "4", "5")
.limit(3)
.map(Integer::parseInt)
.forEach(sum::addAndGet)
.run()
.whenComplete((r, t) -> System.out.println("Sum: " + sum.get()));
> Sum: 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment