举个例子,一个接口,有多个类实现:
interface parent {...}
class child1 implements parent {...}
class child2 implements parent {...}
...
...用一个map来进行管理
class manager {
private static Map<Class, parent> cache = new HashMap<Class, parent>();
static {
cache.put(child1.class, new child1() );
cache.put(child2.class, new child2() );
...
...
}

public static <T> T get(Class<T> klass) {
return (T) cache.get(klass);
}
}我希望可以这样操作 child1 = manager.get(child1.class) 不需要类型转换
但总是出warning Type safety...或者错误,应该怎样做呢?