Created
November 6, 2012 14:41
-
-
Save wsoczynski/4025093 to your computer and use it in GitHub Desktop.
Optional 2
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
class Main { | |
public Optional<String> someValue = Optional.absent(); | |
public static void main(String... arguments){ | |
Main m = new Main(); | |
String foo = m.someValue.or("default value"); | |
System.out.println(foo); //outputs "defaultValue" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment