I have got this situation:
public abstract class Parent {
    public Parent(){}
}
public class Child extends Parent{
    public Child(){
    }
}
public class Main {
    public static void main(String[] args) {
        HashMap<Child, Double> mapChild = new HashMap<>();
        HashMap<Parent, Double> mapParent = new HashMap<>();
        foo(mapChild, new Child()); //Wrong 1 arg type
        foo(mapParent, new Child());
    }
    public static void foo(HashMap<Parent, Double> x, Parent parent){
        x.put(parent, 5.0);
    }
}
This code does not work, because foo(mapChild, new Child()) said - "Wrong argument type".
 I tried somethig with Wildcards, but i think it cant work with it. I can create second foo method, but i do not want to duplicate code.  
Any ideas?
 
     
    