I tried to wrap my head around a problem I cannot seem to find an answer for. Consider the following 2 examples:
{
// this works.
Consumer<CharSequence> c = F -> {};
test(c);
}
static void test(Consumer<? super String> c) { /* content */}
and:
{
// doesn't compile
List<Consumer<CharSequence>> list = new ArrayList<>();
test(list);
}
static void test(List<Consumer<? super String>> list) { /* content */ }
There might be a valid reason why the second example is not compiling/type-safe, but I cannot find/deduct this reason. So any help in clarifying this is appreciated.