I have a type-parameterized method but I can't call getClass
on the type-parameterized parameter because it can be null
, so the only solution I see is to get the Class
from the type parameter itself, somehow:
public <T> Class myMethod(T obj)
{
//can't do this: return obj.getClass() because null is permitted.
}
Aucun commentaire:
Enregistrer un commentaire