Determining the Type for a generic method parameter at runtime

后端 未结 2 590
忘了有多久
忘了有多久 2021-01-13 19:27

Given the a class with the following structure. I am trying to determine the type of the parameter T assigned by the caller of the generic method.

public cl         


        
2条回答
  •  日久生厌
    2021-01-13 20:25

    You can't do that. What you could do is make the method signature like this:

    public boolean isSupportable(Class type)
    

    Then you can use the given class to check the type.

提交回复
热议问题