1)
OptionalInt::of
should accept argument int, but why the following can compile?
Integer boxed=2;
Optional<OptionalInt> optInt=Optional.ofNullable(boxed).map(OptionalInt::of);
Optional.ofNullable(boxed)
should return Optional<Integer>
, not int.
2) why the following cannot compile?
Optional.ofNullable(boxed).flatMap(OptionalInt::of);