4 ms·
There is a way-ish, which is passing a Class<T> as an additional parameter and doing clazz.newInstance(). Definitely not pleasant though.
by ohgodplsno 6y ago
There is a way-ish, which is passing a Class<T> as an additional parameter and doing clazz.newInstance().
Definitely not pleasant though.
- Felk 6y agoFor that particular use case it may be better to pass a constructor reference / new instance supplier to not rely on reflection.