I have a generic class A, and I’m in a method where I have to create an instance of A based on the class the given object is. That is, I have:
public void (Object obj) {
Class<?> c = obj.getClass();
A<c> = ...;
}
However, on the third line Eclipse says that c cannot be resolved to a type. When I remove the generic parameter, I get “A is a raw type. References to generic type A should be parameterized.”
What would be the correct way to go here?
Thanks.
or even better
or if you just need the Class