Java.lang.Class.isAssignableFrom() Method

Description

The java.lang.Class.isAssignableFrom() 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.

Declaration

Following is the declaration for java.lang.Class.isAssignableFrom() method

public boolean isAssignableFrom(Class<?> cls)

Parameters

cls -- This is the Class object to be checked.

Return Value

This method returns the boolean value indicating whether objects of the type cls can be assigned to objects of this class.

Exception

NullPointerException -- if the specified Class parameter is null.

Example

The following example shows the usage of java.lang.Class.isAssignableFrom() method.