1

don't know how to do this, but is there any way to do something like this

public class Service<T>{

    public T save(T object){
        //GenericDao is a generic class
        GenericDao<object.class> gdao = new GenericDao<>();
        gdao.persist(object);
        //do some stuffs
    }
}

I want pass the class type of the object to instantiate a generic class

4

1 に答える 1

2

GenericDao<T>の代わりに使用しGenericDao<object.class>ます。

于 2013-07-17T22:18:38.940 に答える