interface Foo<T> { ... }
class Bar implements Foo<Baz> { ... }
I’ve got a Bar object. How to get the value of T for it (Baz)?
So far, I only managed to get the interface and T, but I can’t see a way to get its value.
Thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Of course, in the general case, you should iterate over the array, rather than assuming it has excatly one element (
[0]). With the above example, you can castactualTypetojava.lang.Class. In other cases it may be different (see comment by meriton)