Created
December 15, 2019 03:28
-
-
Save benweidig/1eb74b5587f8c853dd17e83b490c681f to your computer and use it in GitHub Desktop.
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
Optional<String> withValue = Optional.of("definitly a string"); | |
String s1 = withValue.get(); | |
Optional<String> noValue = Optional.empty(); | |
String s2 = noValue.get(); | |
// ^^^^^^^^^^^^^ this throws NoSuchElementException! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment