Y
Y
Yasuro2019-05-11 11:51:51
Java
Yasuro, 2019-05-11 11:51:51

How to parametrize a List with a class obtained using Reflection?

5cd68c7621345095745670.png
So, of course, it doesn't work.
How is it implemented correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2019-05-11
@Yasuro

Generics are instructions to the compiler, and reflection works at runtime. When the compiler processes the type parameters, there can be no data from reflection yet. And when reflection starts to work, the types are already erased . These worlds will not meet.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question