isAssignableFrom always returns false

NullPointerException
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?

shriakhilc

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related