开发者

Create java Parameterized Type on the fly

How to create a java.lang.reflect.Type of type List<T> on the fly if I know T开发者_StackOverflow is of certain type like String.class or Integer.class?


Java parameterized types are subject to type erasure so that generic types are lost at runtime. This means that, at runtime, a List<String> is indistinguishable from a List<Integer> or a List<Object>, without inspecting the elements in the list.

All this to say, you don't need to worry about the parameterized type at all. You can just create a List.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜