Last active
May 22, 2019 14:52
-
-
Save Gabbendorf/2d34800f4aa0921f6d0c703f191fd20f to your computer and use it in GitHub Desktop.
Java Optional: example that throws an IndexOutOfBoundsException
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
public Member memberById(List<Member> members, int memberId) { | |
return members.stream() | |
.filter(member -> member.getId() == memberId) | |
.collect(Collectors.toList()) | |
.get(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment