Find the class of the generic object
- by Mgccl
Suppose I have the following class.
public class gen<T> {
public gen(){
}
Class<T> class(){
//something that figures out what T is.
}
}
How can I implement the class() function without pass any additional information?
What I did is here, but I have to pass a object of T into the object gen.
public class gen<T> {
public gen(){
}
Class<T> class(T var){
return (Class<T>) var.getClass();
}
}