2

Hi I have quiet a simple code that returns me an error

    void changeHeaders(HttpURLConnection url){
        Map<String, Iterable<String>> m ;
        m = url.getHeaderFields();//<-- this line gives an error
        ...
    }

The error is: Type mismatch: cannot convert from Map<String,List<String>> to Map<String,Iterable<String>>

Why I can not convert List to Iterable?

  • 6
    http://stackoverflow.com/questions/2745265/is-listdog-a-subclass-of-listanimal-why-arent-javas-generics-implicit – assylias Jun 10 '13 at 13:01

1 Answers1

7

Because of generics. You have to use something like:

Map<String, ? extends Iterable<String>> m;
Harald K
  • 26,314
  • 7
  • 65
  • 111