I have the following method:
public Comparator<T> getComparator() throws ReflectiveOperationException {
String className = "some.ClassName";
Class<Comparator<T>> c = Class.forName(className); // (1)
return (Comparator<T>) c. newInstance();
}
In the line (1) I get this error:
Type mismatch: cannot convert from Class <capture#1-of ?> to Class<Comparator<T>>
What's wrong in this code and how should I make an instance of Comparator<T>
?
Aucun commentaire:
Enregistrer un commentaire