jeudi 17 mars 2016

Java Reflect API - isAssignableFrom, Extends/Implements

In Java Reflect API, in .isAssignableFrom methods in Class has its javadocs saying that it will return true if "the class or interface represented by this Class object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified Class parameter".

The question is whether .isAssignableFrom will return true if on a class that implements Interface, or it only returns true when "extends" is used? In other words, what will happen and why in case:

public class MyClass implements MyInterface{}

MyInterface.isAssignable(MyClass.class) == false/true ?





Aucun commentaire:

Enregistrer un commentaire