Skip to content

Instantly share code, notes, and snippets.

@pierrefevrier
Created April 25, 2017 13:57
Show Gist options
  • Save pierrefevrier/ab7f411567cfe47a9e364fac2479d51f to your computer and use it in GitHub Desktop.
Save pierrefevrier/ab7f411567cfe47a9e364fac2479d51f to your computer and use it in GitHub Desktop.
Stream samples
final Optional<Item> foundItem = myCollection.stream()
.filter(item -> item.isTheOneIWant())
.reduce((a, b) -> {
throw new RuntimeException("More than item item found !");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment