public class Admin extends Ability implements Listener
And
public class Admin implements Listener
System.out.println(Admin.class.isAssignableFrom(Listener.class)); // returns false
Hello I'm checking if class is implementing Listener. however, it always returns false! (Look above code!!) what's wrong?
CodePudding user response:
isAssignableFrom documentation states that it:
Determines 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. It returns true if so; otherwise it returns false.
Admin
is not a superinterface of Listener
. Flip them around and you should get the behavior you desire.