fork download
  1. import java.util.*;
  2.  
  3. class Example {
  4. public static void main(String[] args) {
  5. Map<?, ? extends List<?>> m = new HashMap<>();
  6.  
  7. List<?> list = new ArrayList<>();
  8. list.add(m);
  9. }
  10. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:8: error: no suitable method found for add(Map<CAP#1,CAP#2>)
    	list.add(m);
    	    ^
    method Collection.add(CAP#3) is not applicable
      (argument mismatch; Map<CAP#1,CAP#2> cannot be converted to CAP#3)
    method List.add(CAP#3) is not applicable
      (argument mismatch; Map<CAP#1,CAP#2> cannot be converted to CAP#3)
  where CAP#1,CAP#2,CAP#3 are fresh type-variables:
    CAP#1 extends Object from capture of ?
    CAP#2 extends List<?> from capture of ? extends List<?>
    CAP#3 extends Object from capture of ?
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
stdout
Standard output is empty