I have the following two classes:
class Generic<T>
{
}
class Foo extends Generic<Student>
{
}
Inside the Generic
I have a method which I need to get the name of the class that is being passed through T
Is this possible in Java? I know in C# I would just use typeof
.
I have tried to do the following:
String className = new TypeToken<T>() {}.getClass().getName().toString();
This however does not provide the name and only provides Generic$1
>() {}`) by looking at the type parameters of its generic supertype; but that type parameter is the type variable T for that type token.