Home > Back-end > About Type interface and ParameterizedType interface between strong doubt ~!!
About Type interface and ParameterizedType interface between strong doubt ~!!
Time:09-21
, there is a doubt:
public class GenricDaoImpl Implements GenricDao {
Private Class<?> EntityClass;//the type of entity class
Public GenricDaoImpl () { EntityClass=(Class<? & gt;) ((ParameterizedType) (enclosing getClass () . GetGenericSuperclass ())). The getActualTypeArguments () [0]; } }
Type Type=this. GetClass () getGenericSuperclass (); ParameterizedType ParameterizedType=(ParameterizedType) type;
ParameterizedType interface is a Type of interface, Class Class Type is implementation Class;
But Class Class doesn't implement ParameterizedType interface, what is strong to no error;
Class Class didn't rewrite the getActualTypeArguments () method;
I wrote a similar since the Demo, called the com. Itany. C always be cast to com. Itany. B, the code is as follows:
interface A {} Interface B extends A {} Implements A class C {} Public class Main { Public static void main (String [] args) { A, A=new C (). B=B (B) a; } }