If we have class as shown below:
Class ClassA {
}
To create an instance of classA using reflection, we either get reference to the default constructor and invoke it or call Class.forName(".ClassA").newInstance()
The question is how do I achive the same thing for a class that takes generic type.
Say I have a class
public class ClassA<T> implements IClassA<String, T> {
public ClassA(Class<T> clazz) {
super(clazz, clazz.getSimpleName());
}
}
If we want to create an instance of type ClassA we do the following:
ClassA<ClassB> object = new ClassA<>(ClassB.class);
So, If I know fully qualified class names for ClassA and ClassB, will I be able to create an instance at runtime.
Thanks for your help in advance...
-Chandra