How to get type of generic | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

How to get type of generic

I have something like this public <T> void getXxx(Response<T> resp){ } I want to check if T is String for example

10th May 2017, 9:58 PM
Steve Tchatchouang
Steve Tchatchouang - avatar
1 ответ
+ 2
There is no easy way. Why you need it at all? You doing something wrong if logic of your code depends ot generic type. Generic type should be used in places where type of data does not matter.
10th May 2017, 10:44 PM
Jeth
Jeth - avatar