Java – how to get foo Object Value?

(this is a follow-up to my previous question)

I have a foo Object, foo Foo < T > is an interface

How to get hidden in The following type value?

Note that this is not trivial, because foo can be an object such as the bar < string > class, where bar < T > implements foo < T > or some anonymus classes that implement the interface floatfoo, where floatfoo extends foo < float > I need a solution for all situations

Thanks in advance:)

Solution

It is impossible to use reflection because @ l exists in Java genetics_ 404_ 1 @ problem At runtime, the type defined for the generic class foo has been deleted, so using reflection on this class will not produce its generic type This type information is only used for compiling type security

C # does not have this problem and can access the templated types of classes

This is an overview of the differences

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>