Quantcast
Channel: User Federico klez Culloca - Stack Overflow
Viewing all articles
Browse latest Browse all 485

Answer by Federico klez Culloca for Does method Optional.of do a type conversion?

$
0
0

Because in your second example Optional.of() expects an X and new Y()is an X.

But, as you state, an Optional<Y> is not an Optional<X>, hence the first example doesn't work.

More generally a A<X> is not a A<Y>, no matter what X and Y are.


Viewing all articles
Browse latest Browse all 485

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>