Check if a class is subclass of another class in Java

Posted by craesh on Stack Overflow See other posts from Stack Overflow or by craesh
Published on 2011-01-03T12:47:19Z Indexed on 2011/01/03 12:53 UTC
Read the original article Hit count: 210

Filed under:
|
|

Hi!

I'm playing around with Java's reflection API and trying to handle some fields. Now I'm stuck with identifying the type of my fields. Strings are easy, just do myField.getType().equals(String.class). The same applies for other non-derived classes. But how do I check derived classes? E.g. LinkedList as subclass of List. I can't find any isSubclassOf(...) or extends(...) method. Do I need to walk through all getSuperClass() and find my supeclass by my own?

Thanks!
craesh

© Stack Overflow or respective owner

Related posts about java

Related posts about class