Consider a class which implements IReader but has a private no-arg default constructor.Then obviously you cant create Objects using a default constructor.Consider this :-
class Example extends IReader {
private Example{
}
@Override
public void myFunction(){
//your code goes here
}
}
Obviously you cant create instances of class Example outside the class ,in this case
You can do two things:-
1)Use reflection to create objects
private static <T extends IReader> Vector<T> Read(Class<T> cl)
{
Vector<T> List = new Vector<T>(); // Create new Vector
// Create new instance of the type T
T Dataset = cl.newInstance();
Dataset.myFunction();
// Add to the Vector
List.add(Dataset);
// return Vector
return List;
}
2)You can pass an Object of type T and simpy add to the list
private static <T extends IReader> Vector<T> Read(T obj)
{
Vector<T> List = new Vector<T>(); // Create new Vector
// Create new instance of the type T
obj.myFunction();
// Add to the Vector
List.add(obj);
// return Vector
return List;
}