Rather obtusely you can do
OptionalInt oi = OptionalInt.of(1);
oi.ifPresent(i -> IntStream.of(i).map(j -> j + 1).forEach(System.out::println));
However it is not clear why OptionalInt
doesn't have the same methods as IntStream
although I note Optional
has a subset of Stream