I don't understand how generics in Java fully works. I have similar situation which I simplified in code below:
public static void main(String[] args) {
Map<String, Collection<B>> map1 = test();
Map<String, List<B>> map2 = test();
Map<String, ArrayList<B>> map3 = test();
}
private static Map<String, ArrayList<B>> test() {
return null;
}
when creating map1 or map2 I get an error which says incompatible type - it was expecting ArrayList, but got Collection/List instead.
How do I solve such problem?