Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import java.util.Optional;
public class OptionalSample {
public static void main(String[] args) {
Integer max = null;
Optional<Integer> nullableMax = Optional.ofNullable(max);
nullableMax.orElseThrow(RuntimeException::new); // 例外スローする
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment