java - Creating a generic object using a Class<?> variable -


i have generic class a, , i'm in method have create instance of based on class given object is. is, have:

public void (object obj) {   class<?> c = obj.getclass();   a<c> = ...; } 

however, on third line eclipse says c cannot resolved type. when remove generic parameter, "a raw type. references generic type should parameterized."

what correct way go here?

thanks.

public <c> void (object b) {   class<c> c = b.getclass();   a<c> = ...; } 

or better

public <c> void (c b) {   class<c> c = b.getclass();   a<c> = ...; } 

or if need class

public <c> void (class<c> clazz) {   a<c> = ...; } 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -