Hacker News new | ask | show | jobs
by ohgodplsno 1903 days ago
There is a way-ish, which is passing a Class<T> as an additional parameter and doing clazz.newInstance().

Definitely not pleasant though.

1 comments

For that particular use case it may be better to pass a constructor reference / new instance supplier to not rely on reflection.