Main.java:7: error: no suitable method found for add(String)
list.add(s); // does not compile
^
method Collection.add(CAP#1) is not applicable
(argument mismatch; String cannot be converted to CAP#1)
method List.add(CAP#1) is not applicable
(argument mismatch; String cannot be converted to CAP#1)
where CAP#1 is a fresh type-variable:
CAP#1 extends String from capture of ? extends String
Main.java:8: error: no suitable method found for add(CAP#1)
list.add(list.get(0)); // doesn't compile either
^
method Collection.add(CAP#2) is not applicable
(argument mismatch; String cannot be converted to CAP#2)
method List.add(CAP#2) is not applicable
(argument mismatch; String cannot be converted to CAP#2)
where CAP#1,CAP#2 are fresh type-variables:
CAP#1 extends String from capture of ? extends String
CAP#2 extends String from capture of ? extends String
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors