Created
December 17, 2017 22:50
-
-
Save ouyi/1e121a273d3c0bea08d38569009b4e9f to your computer and use it in GitHub Desktop.
java 8 test whether a nullable String is empty or not
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
// java 8 test whether a nullable String is empty or not | |
if (Optional.ofNullable(s).orElse("").isEmpty()) { | |
// s is null or empty | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment