Created
April 25, 2017 13:57
-
-
Save pierrefevrier/ab7f411567cfe47a9e364fac2479d51f to your computer and use it in GitHub Desktop.
Stream samples
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
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