0

这可以生成对象的实例吗?

 public <?> getDAO ( Class<?>DAO){

      //if using this DAO class is permitted or DAO class exists
    //we have HashMap map
return map.get(DAO);

}

或者也许是

public <T> T getDAO ( <T extends AGenericDAO> DAO){ // GenericDAO<E,I>

          //if using this DAO class is permitted or DAO class exists
        //we have HashMap map
    return map.get(DAO);

    }

?

4

1 回答 1

1

听起来你想要的是:

public <T extends AGenericDAO> T getDAO(final Class<T> daoClass) {
    return daoClass.cast(map.get(daoClass));
}

哪里map有类型java.util.Map<Class<? extends AGenericDAO>, AGenericDAO>

于 2013-07-10T02:58:20.030 回答