Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benweidig/0d7aaeabfe2074524ad247de4af5bc9c to your computer and use it in GitHub Desktop.
Save benweidig/0d7aaeabfe2074524ad247de4af5bc9c to your computer and use it in GitHub Desktop.
// Case 1: We know there's a value
Optional<String> withValue = Optional.of("definitly a string");
// Case 2: We 're not sure
Optional<String> maybeValue = Optional.ofNullable(null);
// Case 3: We're sure there's no value
Optional<String> noValue = Optional.empty();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment