Is there any difference between
List
and
List extends Map>
<
As you mentioned, there could be two below versions of defining a List:
List extends Map> List>2 is very open. It can hold any object type. This may not be useful in case you want to have a map of a given type. In case someone accidentally puts a different type of map, for example, Map. Your consumer method might break.
In order to ensure that List can hold objects of a given type, Java generics introduced ? extends. So in #1, the List can hold any object which is derived from Map type. Adding any other type of data would throw an exception.