Knowing type of generic in Java

后端 未结 7 1134
醉话见心
醉话见心 2020-12-03 16:17

I have a generic class, says :

MyClass

Inside a method of this class, I would like to test the type of T, for example :

         


        
7条回答
  •  感动是毒
    2020-12-03 16:48

    As it was already stated you can get only generics-related information available at the static byte code level.

    It's possible to resolve type arguments values and check if one type may be used in place of another then.

提交回复
热议问题