Created
January 5, 2016 21:42
-
-
Save shehaaz/ba7d21d1eae574d0b28c to your computer and use it in GitHub Desktop.
Optional in Java 8
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> optional = Optional.of("Bam"); | |
if(optional.isPresent()) | |
{ | |
System.out.println(optional.get()); //Bam | |
} | |
optional = Optional.empty(); | |
System.out.println(optional.orElse("test")); //test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment