I have written the following generic function in Java:
public <T extends MyClass> void loadProperties(String in_strPath)
{
// ...
}
The type T can be any of 3 different classes which are children of MyClass. Let's call those 3 classes MyClassV1, MyClassV2 and MyClassV3. I would like to print the name of the class that corresponds to T from whithin loadProperties. I tried doing this:
Class<T> c = T.class;
T instance = c.newInstace();
System.out.println(instance.getClass().getName());
But it does not work. Thanks for any advice.