Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

isAssignableFrom always returns false

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?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading