I want my T type to be instance of java.lang.reflect.Type interface or java.lang.Class<T>
I have created sample code like below
public class Car<T extends Type> {
private T t;
public Car(T t) {
this.t = t;
}
public static void main(String[] args) {
Car<String.class> car = new Car(String.class);//Error String.class
}
}
I know above in above example I can use Class<T> instead of using T. I wanted to know if there is any way in which T can be made to understand that it is of Type or Class?
Instead of
Car<String.class>, writeCar<Class<String>>.String.classis an object. Between the angle brackets you must specify a type. The type you’re looking for isClass<String>.