Class.isAssignableFrom(Class <?> cls) has the following syntax.
public boolean isAssignableFrom(Class <?> cls)
In the following code shows how to use Class.isAssignableFrom(Class <?> cls) method.
//from w w w . j ava2s . c o m public class Main { public static void main(String[] args) throws Exception { Main cls = new Main(); Class c = cls.getClass(); Class bClass = BaseClass.class; boolean retval = bClass.isAssignableFrom(c); System.out.println("Return Value = " + retval); retval = c.isAssignableFrom(bClass); System.out.println("Return Value = " + retval); } } class BaseClass extends Main { public BaseClass() { } }
The code above generates the following result.