How to Cast the Class Object of a Generic Type to a Specific Instance of that Type

前端 未结 1 880
一个人的身影
一个人的身影 2021-01-13 17:47

I have a generic interface, lets call it GenericInterface. I need to pass the class object of that interface to a method that expects (specifi

1条回答
  •  孤街浪徒
    2021-01-13 18:14

    There are similar questions:

    • Java generics - get class?
    • How to get a class instance of generics type T

    The short answer is, that there is no way to find out the runtime type of generic type parameters in Java.

    0 讨论(0)
提交回复
热议问题