Reputation: 686
can anyone tell me why the put is giving me an error?
static HashMap<Class, ? extends BaseSystem> systems;
public <T extends BaseSystem> EntityManager()//constructor
{
systems=new HashMap<Class, T>();
}
public static <T extends BaseSystem> void addSystem(Class c, T system)//store a system for later reference
{
systems.put(c, system);
}
Upvotes: 0
Views: 137
Reputation: 533492
The most likely problem is that the T in the first method and the T in the second method are not automagically considered the same. In other works you have two different types which both extends BaseSystem but could be unrelated.
You need to define T once on the class and use it consistently or just use BaseSystem and not use generics.
BTW: On a more basic level, don't confuse static initialisation and instance intialisation. If you are setting a static field in a constructor you have a design issue.
Is there any relationship between the class and the T
system?
Upvotes: 15