Hi Manfred,
Thanks for your reply.
Yes - I have read it already. And I find it a little bit
misleading. That's because
? extends Pair<
String,?> is particularly pointing to a Pair type, not
the wildcard. It would work if not the erasure (I mean List<Pair<String,?>>
, although we would get a runtime error). But saying List<? extends ....>
we are safe, because it doesn't matter what we have there - we can't add
anything anyway ... Note, that if we had List<? extends Pair<String,String>>
then we wouldn't be able to stuff a List<Pair<String,Integer>>.
So the inside type parameter is binding regardless of whether the
parameterized type is a part of a bounded wildcard or not. If it is, then
the only reason why compiler allows it is the it knows you can't add
anything to it anyway. That's how I see it. But I might be wrong
I'll be happy to read what others think about it.
Cheers,
Adrian