How to get the .class of a Generics defined entity? [duplicate]

不打扰是莪最后的温柔 提交于 2019-12-01 20:33:05

You can't.

The closest approximation to what you want is to use (Class<List<String>>) List.class.

This is because there is no List<String>.class, because at runtime, List<String>, List<Banana>, List<FruitSalad>, and List are all the same in Java. This is deliberately done for a whole bunch o' reasons, and it's called type erasure.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!