How to get class of generic type when there is no parameter of it?

后端 未结 5 849
星月不相逢
星月不相逢 2020-12-17 21:04

I just learned about this fine looking syntax

Collections.emptyList()

to get an empty List with elements which a

5条回答
  •  Happy的楠姐
    2020-12-17 21:25

    As you mentioned, Java generics are build time only. They are not used at run time.

    Because of this, the old approach you were using will be your only way to accomplish this.

提交回复
热议问题