This question already has an answer here:
If I have Class<?> t = T.class
, how can I construct the class of T[]
dynamically, i.e. without naming T
in the source code?
I think it should be possible to do this as
java.lang.reflect.Array.newInstance(t, 0).getClass()
but that feels kind of round-about. Is there a shorter way to achieve this without actually constructing an array of the type in question?
Aucun commentaire:
Enregistrer un commentaire