Created
June 4, 2016 01:40
-
-
Save defndaines/3394f52f5cd3d5469d185d6f342d81dc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import java.util.Arrays; | |
| import java.util.Collections; | |
| import java.util.List; | |
| import java.util.Optional; | |
| List<Long> numbers = Collections.emptyList(); | |
| Optional<Long> result = numbers.stream().reduce(Math::max); | |
| // result.orElse(-1L) == -1L; | |
| numbers = Arrays.asList(52L, 127L, 1337L); | |
| result = numbers.stream().reduce(Math::max); | |
| // result.get() == 1337L; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment