How to test if one java class extends another at runtime?

Armand picture Armand · Aug 17, 2010 · Viewed 86.3k times · Source

How to I test if a is a subclass of b?

Class<?> a = A.class;
Class<?> b = B.class;

Answer

meriton picture meriton · Aug 17, 2010

Are you looking for:

Super.class.isAssignableFrom(Sub.class)