Suppose I have interface (or superclass, doesn't matter) Program and implementation Firefox. I would like to define a map in some classes state as Map<Long,Program> mapOfPrograms then in a setter set mapOfPrograms = new TreeMap<Long,Firefox>(); through dependency injection. I need to be able to do mapOfPrograms.put(1l,new Firefox()); or mapOfPrograms.put(1l,(Program)(new Firefox())); I then need to be able to get and use these objects.
I'm getting the error Type Mismatch: cannot convert from Map<Long,Program> to TreeMap<Long,Firefox>. Doesn't matter if Program is an interface or superclass.
How do I overcome this issue?