jeudi 25 juillet 2019

Strange behavior of asSubclass method

Now i'm playing around with reflection and encounter with not quite clear behavior for me.

        Class<? extends List> listClass = ArrayList.class.asSubclass(List.class);

        System.out.println(listClass.isInstance(ArrayList.class));  //print false
        System.out.println(listClass.getSimpleName());// print ArrayList

Sorry if my question is stupid and isn't new but i can't understand why

listClass.isInstance(ArrayList.class) return false, although

listClass.getSimpleName() return ArrayList

Can someone explain this behavior? Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire