How to use List<? extends Map<String, ?>>

android, java, list

Solution

Okay. That `<? extends Whatever>` is called a bounded wildcard. It will only match your `ArrayList<YourObject>` if `YourObject` belongs to a class implements `Map<String, Something>`, where `Something` can be any class (that one will match the unbounded wildcard `?`).

Your `ArrayList` is totally fine, since that implements the `List` interface. It's your custom `MyOwnObject` that needs to satisfy the above restrictions.

Read more about wildcards here.

Problem

I'm trying to use a constructor of a library i'm using. But i need to pass it this object : ``` List<? extends Map<String, ?>> ``` But i have only an object : ``` data = ArrayList<MyOwnObject>. ``` I don't understand how i adapt my data to fit in `List<? extends Map<String, ?>>`. Thanks.

Original source