Is there any way to store the generic parameter type passed in at construction to a parameter. My goal:
class generic<T> {
Class<T> type;
public generic() {
super();
this.type = //Something that gets class from T
}
}
What I'm currently doing is this:
class generic<T> {
Class<T> type;
public generic(Class<T> type) {
super();
this.type = type;
}
}
It seems silly to have to specify the class twice, but I'm not sure of how else to do it. I think this might be possible with reflection, but I haven't investigated that yet. Is there a more straightforward way? If not (as an aside) why the information loss?