For the below Class Structure:
class BaseClass{}
class A extends BaseClass{}
class B extends BaseClass{}
I have this method in main:
public static void goThroughMap(Map<String,Collection<? extends BaseClass>> myMap) {}
Now to call this method , i am doing something like:
Map<String,Collection<B>> myMap = new HashMap<>();
goThroughMap(myMap); // is causing a compile time error
The error is:
The method goThroughMap(Map<String,Collection<? extends BaseClass>>) is not applicable for the arguments (Map<String,Collection<B>>)
So, how should i modify my method parameters to make this work? Any pointers for further reading are welcome.
I have seen related questions by other users(see links below), but none of them seem solve the issue here: