I have this code:
private <D extends Object> void foo(D d) throws IllegalAccessException, InstantiationException {
d = d.getClass().newInstance(); // Compilation error: "Incompatible types: Required D, Found: Object"
}
Why do I get this error?
To my understanding, the compiler knows that d is D type (which extends Object)...?
Aucun commentaire:
Enregistrer un commentaire