Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
An Optional wrapping a value which can be null
public static Optional<String> stringNullableOptional(String input) {
if (!new Random().nextBoolean()) {
input = null;
return Optional.ofNullable(input);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment